Introduction
The Blink example is the “Hello, World!” of microcontroller programming. It’s the first sketch most makers run, and for good reason: it teaches you the fundamentals of digital output, timing, and the setup/loop structure that underpins every Arduino project. In this tutorial, you’ll load the classic Blink sketch onto an Arduino Uno (simulated in Velxio), and watch an LED pulse on and off every second. No extra components required—the Uno has a built-in LED on pin 13.
Circuit Walkthrough
This project uses a single component: the Arduino Uno board. Inside the simulation, the Uno is placed at coordinates (100, 100). The board has an on-board LED connected to digital pin 13. Because that LED is already wired internally, no external components or wires are needed. The Arduino’s built-in LED is the load—a small surface‑mount LED with a current‑limiting resistor embedded on the board. When pin 13 is HIGH (5 V), the LED lights; when LOW (0 V), it turns off.
Note that the wires array is empty in this example, because all wiring is internal. If you were to build this on a real breadboard, you would connect an external LED (with a 220 Ω resistor) between pin 13 and GND. But for the built‑in version, you can just run the code and see the result.
Code Walkthrough
Let’s examine the firmware line by line. The full sketch is shown below:
// Blink LED Example
// Toggles the built-in LED on pin 13
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}1. Comments
The first two lines (starting with //) are comments. They are ignored by the compiler and serve only to document the code. Always add comments to explain what your code does!
2. void setup()
The setup() function runs once when the Arduino powers on or resets. Inside it, we call pinMode(13, OUTPUT) to configure digital pin 13 as an output. Without this, the pin would be an input (high‑impedance) and the LED would not light.
3. void loop()
After setup() finishes, the loop() function runs repeatedly, over and over. Inside the loop:
digitalWrite(13, HIGH)– sets pin 13 to 5 V, turning the LED on.delay(1000)– pauses the program for 1000 milliseconds (1 second).digitalWrite(13, LOW)– sets pin 13 to 0 V, turning the LED off.delay(1000)– another 1‑second pause.
The result: the LED blinks at a 1‑second interval—1 s on, 1 s off, forever.
Key Concepts
- Digital I/O pins: Arduino pins can be configured as inputs (read sensors) or outputs (drive LEDs, motors, etc.). Here we use an output to drive an LED.
- pinMode(): Must be called in
setup()for each pin you want to use. - digitalWrite(): Sets a pin HIGH (5 V) or LOW (0 V).
- delay(): Halts the program for a given number of milliseconds. While simple, long delays block other tasks—in real projects you’ll often use
millis()for non‑blocking timing. - setup() / loop(): The mandatory Arduino structure. Initialization goes in
setup(); the main program logic goes inloop().
Common Pitfalls & Debugging Tips
- Wrong pin number: The built‑in LED is on pin 13. If you use another pin with no LED attached, nothing will light. Always check your board’s pinout.
- Forgetting pinMode(): If you omit
pinMode(), the pin remains an input and the LED may glow dimly or not at all. Always set the mode insetup(). - Missing delay(): Without delays, the LED will toggle so fast it appears permanently on (or off). Human eyes can’t see changes faster than ~20 Hz.
- Blocking delays: For more complex projects, long
delay()calls prevent the Arduino from doing anything else. Learn to usemillis()for non‑blocking timing.
Suggested Extensions & Variations
- Change blink speed: Alter the
delay()values to 500 ms (0.5 s) or 2000 ms (2 s). - External LED: Add an external LED with a 220 Ω resistor on a breadboard, connected to pin 13 and GND. Modify no code—just wire it up.
- Multiple LEDs: Use pins 12, 11, 10 etc. to control several LEDs in a pattern (e.g., chase effect). Add
digitalWriteanddelaycalls for each. - Serial monitor output: Add
Serial.begin(9600)insetup()andSerial.println("LED on")/Serial.println("LED off")in the loop to see messages alongside the blinking. - Use a button: Combine with a pull‑down resistor and a button to turn the LED on only when the button is pressed.
Try It Live on Velxio!
Ready to blink your first LED? Head over to the Blink LED example on Velxio and run the simulation right in your browser. You can edit the code, change pin numbers, or add extra components—all without soldering a single wire. Experiment fearlessly and see your changes instantly!