The Arduino Nano development board, or simply Arduino Nano, is a popular choice for microelectronic projects. Getting started with the Arduino Nano will explain and show how to hook the board up to a LED, set up and connect it to the Arduino IDE and how to upload a simple sketch to make the LED blink on and off.
These are the parts that were used:
These were the parts that were used. Most are available from BangGood, eBay and RS Components. Direct links to some of the parts are supplied lower down.
- Arduino Nano
- Mini-B USB cable
- Breadboard and solderless breadboard jumper cable set
- 220 Ohm resistor
- 3 mm or 5mm LED
- Arduino IDE installed on a PC
Wiring the components
Using a breadboard, wire the Arduino Nano, resistor and LED together. Here D2 was wired, but any digital pin can be used. The pins will probably be marked. D2 and the ground (GND) pin should be right next to each other.
The LED
Out of the box, LEDs will have a long leg (anode) and a short leg (cathode). The specifications (forward Voltage or Vf @ a specific current or If) of LEDs (usually size and colour dependent) will be available from the manufacturer/datasheet.
LEDs can be connected directly to a breadboard. The long leg is connected to the digital write pin of the Arduino Nano and the short leg to a resistor.
The resistor
Each digital pin of the Arduino Nano supplies 5V DC, so in order not to overload the LED (which usually has a forward Voltage (Vf) of about 2 – 3 V DC @ about 20 mA), a 220 Ohm resistor is usually safe to use.
Resistors can be connected directly to a breadboard. One leg is connected to the cathose of the LED and the other leg is connected to the ground (GND) pin of the Arduino Nano. It doesn’t matter which side of the resistor is used where.
Using the Arduino IDE
After the wiring has been done, the Arduino Nano should be connected and configured to be programmed by the Arduino IDE. Programming is done by uploading ‘sketches’ from the PC, on which the IDE is installed, onto the Arduino Nano.
Board drivers for the Nano are automatically installed when the software package is installed, but after connecting the PC with the Arduino Nano using a Mini-B USB cable, additional operating system drivers might start to install automatically. When on-board LED of the Arduino Nano is lit, the Arduino IDE can be opened.
The Arduino IDE can be used to program a multitude of microcontroller boards. In order to use board-specific configuration, the board settings and the port settings needs to be configured each time a new microcontroller board is connected.
In this case, Arduino Nano can be selected from the Tools > Board menu. Arduino Duemilanove or Nano w/ ATmega328 can also be used in the case of version 3 boards and Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 can be used in the case of a version 2 boards.
The Arduino IDE also needs to know what communication/serial port (COM port) to use to connect to the board. Selecting the correct port number is a bit of a guess, but generally the highest port number will be correct one. The serial port is selected from the Tools > Serial Port menu.
Uploading the sketch
After the Arduino IDE has been configured correctly, the Arduino Nano can be programmed by uploading a sketch. A great way to get started with any microcontroller board is by uploading a simple ‘tester’ script/code to see if eferything is configured correctly and to start testing the final project code.
In this case, the Blink sketch will be used to tell the microcontroller to switch the wired LED on and then switch it off again – over and over again.
To access the Blink sketch, go to File > Examples > Basics > Blink. This will load the default blinking sketch from the Arduino IDE’s build-in sketch library:
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the Uno, Nano and Leonardo, it is attached to digital pin 13. */ #define LED 13 // define connection of LED, in this case 13 // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(LED, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
On the Arduino Nano, pin 13 also serves as the on-board LED. By uploading the sketch as-is, the on-board LED will blink on and off.
To make the wired LED blink, the pin needs to be replaced to the pin used to wire the LED. In this case it was D2 – so all the 13s can be replaced by 2s.
Sketches are uploaded by pressing the Upload (->) button in the Arduino IDE. After the code has been successfully uploaded, the board will automatically reset and the sketch start to run.