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.
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 !
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.
- Download Arduino (for Windows) here : arduino.madnerd.org (or arduino.org )
- Download drivers here : nano.madnerd.org (or wch.cn )
- Click arduino-1.x.x-windows.exe to install Arduino
- Open arduinoNano_Drivers.zip, and click on setup.exe
- Then click on INSTALL
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.
- Copy the folder on your skecth folder (Documents/arduino)
- Click on the sketch helloworld.ino (inside helloworld 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)
- Click on Upload (Shortkey : CTRL-U )
- Arduino red LED will turn on, then the green led will start to blink fast, finally you should see Upload done on your screen
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
- Check the speed is the same as the one on the sketch (here 9600 bauds)
- You should see “Hello World” , which means we are able to receive messages from our Arduino
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.