In this lesson, you will learn how to program your Arduino to make the Arduino’s built-in LED blink.
Arduino Uno R3
The ‘L’ LED
The Arduino has rows of connectors along both sides that are used to connect to electronic devices and plug-in ‘shields’ that allow the Arduino to do more. However, the Arduino also has a single LED that you can control from your sketches. This LED is built onto the Arduino board and is often referred to as the ‘L’ LED as this is how it is labelled on the board.
The position of this LED is circled in red on the pictures of the Arduino Uno and Leonardo below.
You may find that your Arduino board’s ‘L’ LED already blinks when you connect it to a USB plug. This is because Arduino boards are generally shipped with the ‘Blink’ sketch pre-installed. In this lesson, we will reprogram the Arduino with our own Blink sketch and then change the rate at which it blinks. In Lesson 0, you setup your Arduino IDE and made sure that you could find the right serial port for it to connect to your Arduino board. The time has now come to put that connection to the test and program your Arduino board. The Arduino IDE includes a large collection of example sketches that you can load up and use. This includes an example sketch for making the ‘L’ LED blink.
Load the ‘Blink’ sketch that you will find in the IDE’s menu system under File → Examples → 01.Basics
When the sketch window opens, enlarge it so that you can see the whole of the sketch in the window.
The example sketches included with the Arduino IDE are ‘read-only’. That is, you can upload them to an Arduino board, but if you change them, you cannot save them as the same file. We are going to change this sketch, so, the first thing you need to do is save your own copy that you can change however you like.
From the File menu on the Arduino IDE select the option ‘Save As..’ and then save the sketch with the name ‘MyBlink’.
Attach your Arduino board to your computer with the USB cable and check that the ‘Board Type’ and ‘Serial Port’ are set correctly. You may need to refer back to Lesson 0.
The Arduino IDE will show you the current settings for board at the bottom of the window.
Click on the ‘Upload’ button. The second button from the left on the toolbar.
If you watch the status area of the IDE, you will see a progress bar and a series of messages. At first it will say ‘Compiling Sketch..’. This converts the sketch into a format suitable for uploading to the board.
Next, the status will change to ‘Uploading’. At this point, the LEDs on the Arduino should start to flicker as the sketch is transferred.
Finally, the status will change to ‘Done’.
The other message tells us that the sketch is using 1,084 bytes of the 32,256 bytes available. After the ‘Compiling Sketch..’ stage you could get the following error message:
The clue is at the top here, it probably means that your board is not connected at all, or the drivers have not been installed (if necessary) or that the wrong serial port is selected.
If you get this, go back to Lesson 0 and check your installation.
Once the upload has completed, the board should restart and start blinking.