Arduino Lesson 1. Blink Created by Simon Monk Guide Contents Guide Contents 2 Overview 3 Parts 4 Part 4 Qty 4 The 'L' LED 5 Loading the 'Blink' Example 6 Saving a Copy of 'Blink' 8 Uploading Blink to the Board 9 How 'Blink' Works 11 Blinking Faster 13 Other Things to Do 14 © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 2 of 14 Overview In this lesson, you will learn how program your Arduino to make the Arduino's built-in LED blink. © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 3 of 14 Parts Part Qty Arduino Uno R3 1 USB Lead - type A to B 1 © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 4 of 14 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. © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 5 of 14 Loading the 'Blink' Example 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. © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 6 of 14 © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 7 of 14 Saving a Copy of 'Blink' 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'. You have saved your copy of 'Blink' in your sketchbook. This means that if you ever want to find it again, you can just open it using the File ® Sketchbook menu option. © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 8 of 14 Uploading Blink to the Board 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 staus will change to 'Done'. © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 9 of 14 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. © Adafruit Industries http://learn.adafruit.com/adafruit-arduino-lesson-1-blink Page 10 of 14
Description: