Upload code on an Arduino

Upload code on an Arduino

We are going to see how to upload code on an Arduino Nano on Windows.

Arduino are microcontrollers, the main difference with a computer, it that it can execute only one software.
This makes it more reliable, more suitable to control electronic and last but not least cheaper.

As long as you are not afraid to solder, I suggest you skip the most well know : Arduino Uno to directly use Arduino Nano, which are similar in functionalities but smaller.

These Arduino boards are connected with USB, so you can easily power them, upload code, and send/receive instructions from an computer, a Raspberry Pi, and even (some) phones !

Where should I buy an Arduino Nano?

arduino nano

In this tutoriel, we are going to:

  • Download and install Arduino software
  • Copy a code (sketch)
  • Upload a sketch on the Arduino
  • Debug the sketch
  • Copy library if necessary.

 

Install Arduino

  • Click arduino-1.x.x-windows.exe to install Arduino

arduinoInstall

  • Open arduinoNano_Drivers.zip, and click on setup.exe

CH340 drivers

  • Then click on INSTALL

driversInstall

We are ready to program our Arduino Nano clone.

Copy a sketch

An Arduino program (Sketch) is a folder wih an .ino file.
Let’s see an example, pigetArduino/helloworld

This sketch will transmit Hello World  every 2 seconds on the USB serial port :

  • Download helloworld here
  • Open the file, inside the folder helloworld-master, we have a folder helloworld, this is where the sketch is.

helloWorldFolder

  • Copy the folder on your skecth folder (Documents/arduino)

folderArduino

  • Click on the sketch helloworld.ino (inside helloworld folder)

helloworldino

A sketch must have the same name as the folder
Where is my sketch folder ?

Upload a code on an Arduino

We now have our sketch, we can now copy (upload) it on the Arduino:

We can now copy it (upload it) on an Arduino.

  • In tools, select the board  : Arduino Nano
  • In Port , choose the port of your arduino (if you don’t know which it is, start with the last)

typecartearduino

  • Click on Upload (Shortkey : CTRL-U )

upload

  • Arduino red LED will turn on, then the green led will start to blink fast, finally you should see Upload done on your screen

uploadfinish

Which port is my arduino on ?

Debug a sketch

The most effective way to communicate with our arduino with a computer is serial.

This protocol, will allow you to receive and send text (this will allow us to know what’s going on our Arduino and give him orders).

To talk to our Arduino , we can use the serial monitor.

  • Click on Serial Monitor

upload

  • Check the speed is the same as the one on the sketch (here 9600 bauds)

bauds

  • You should see “Hello World” , which means we are able to receive messages from our Arduino
TX/RX led will turn on each times a message is sent/received

Copy library

In our example, we didn’t need library, but most sketchs will need them.
Libraries adds functionalities to Arduino software to manages a lot more components.
You can download library directly inside Arduino software, (Sketch, include library,  manages library), but a lot of libraries are unavailable.

Most of the times, libraries are available with sketches.
You just need to copy them inside the sketch folder, inside a libraries folder (It doesn’t exists, you need to create it)
But sometimes you will need to find the libraries by yourself.

Every sketches available on madnerd.org, contains (at least) two folders.

  • Sketch folder
  • Libraries folder

Copy these two folders inside your sketch folder.

Comments are closed.