Blink an LED
Part of the First Circuits section of Coddy's Arduino journey. Lesson 1 of 22.
An Arduino Uno is a small computer called a microcontroller. You write a program for it, called a sketch, and the board runs it on its own, again and again, as long as it has power.
Every sketch has two parts:
void setup() {
// runs once, when the board starts
}
void loop() {
// runs again and again, forever
}The board talks to the world through its pins. Pin 13 has an LED wired to it. To light it, make the pin an output in setup(), then set it HIGH (5 volts, on) or LOW (0 volts, off):
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);delay(1000) pauses the sketch for 1000 milliseconds, one second. Put an on, a wait, an off and another wait in loop(), and the LED blinks forever.
Challenge
EasyThe board has an LED on pin 13. Make it blink:
- in
setup(), make pin 13 an output - in
loop(), turn it on, wait a second, turn it off, wait a second
Press Run on the board to watch it, then Check.
Try it yourself
void setup() {
// runs once when the board starts
}
void loop() {
// runs again and again
}
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in First Circuits
1Hello, Board
Blink an LEDSetup and LoopChange the Blink SpeedAn LED of Your OwnTwo LEDs Taking TurnsComments in Your SketchPractice on your own: Arduino playground