Arduino Hello Word – Blink tutorial

This is the easiest and cheapest example about using an Arduino. You need only an Arduino or compatible board and optionally an LED and a resistor. Most of the Arduino boards have an LED connected to the D13 pin.

Here is the source code for the example:

The program has two functions. The setup(), which runs only once, when the board boots up and the second called loop() which runs forever. It is like a while loop with 1==1 condition inside.

Inside the setup() function there is just one command, pinMode(13, OUTPUT). This function tells the board that on the digital pin 13 there will be an output signal.

After finishing the setup(), the loop() function comes, which has got two different commands. The digitalWrite(13, HIGH) tells the board to turn on 5 volts output to the digital pin 13.  HIGH is a constant, which means 5V, and LOW means 0V. The delay(ms) function sets the board to sleep for a given period of time. It takes one parameter, an integer. The delay(500) means 0.5 second.

If you wish you can connect an LED to the board following this schematics:

LED`s longer pin is the (+) terminal
LEDs longer pin is the (+) terminal

Here is how it looks on the breadboard:

Blink example setup on breadboard with Arduino Nano compatible board
Blink example setup on breadboard with Arduino Nano compatible board

Open the Arduino IDE and connect your board with the help of a USB cable. Depending on your board, select the corresponding model under  "Tools->Board:---" menu. After selecting the board click again on the "Tools->Port:" and select the port where your board is connected. In most cases you can select only from one option, that will be your board. If no ports are available than try unplugging and plugging again the board. Paste the example code in the editor than hit (Ctrl+U) or the upload button.

If you connected the wires and uploaded the example code, the led starts to blink. If dont, there are some mistakes. In this case review the wires and the board.