First Sketch: Make an LED Blink
By long tradition (going back to 2006), the first Arduino sketch you write is to make an LED blink.
Arduino pins can be used for input and output, as long as you tell the computer which is which. So in this sketch, we tell the Arduino to set pin 13 to be the LED OUTPUT pin, and then we alternately send electricity to pin 13 (setting the pin HIGH) and cut off the electricity to pin 13 (setting the pin LOW). With each alternation, the LED turns on and off.
We’ll write all the sketches in this book using the Arduino “integrated development environment” (IDE), which, simply put, is special software for writing and uploading code to Arduino.
Parts
- Arduino Uno
- Breadboard
- LED
Install the IDE
Download the Arduino IDE from http://arduino.cc/en/Main/Software, and follow the provided instructions to install it on your computer.
Once you’ve installed the software, open the IDE. You should see a screen that looks something like Figure 1-3.

Figure 1-3. The Arduino IDE on a Mac.
Breadboard the Circuit
The circuit portion of this project is very simple:
Take an LED and place the long lead into pin 13 on Arduino, as you can see in the Figure 1-4 breadboard view.

Figure 1-4. LED long lead inserted into pin 13 on the Arduino (image made with Fritzing.org).
Write the Code
You can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access