PartAndStock
Blog

Blink Your First LED With Arduino: A Step-by-Step Project From Scratch

August 17, 2026 4 min read
Quick answer

The first project for everyone starting out in electronics and programming is almost always the same: blinking an LED on and off. It looks simple, but this project teaches you to build a circuit, upload code to a microcontroller and see how hardware and software work together. In this guide we'll go step by step from scratch.

Parts you'll need

  • 1 × Arduino board (an Uno is ideal to start) and a USB cable
  • 1 × LED
  • 1 × 220–330 Ω resistor (to protect the LED)
  • 1 × breadboard
  • A few jumper wires

All of these parts are already on the beginner component list.

1. Build the circuit

Prepare the circuit before connecting the Arduino to the computer. The LED has two legs: the long leg is positive (anode), the short leg is negative (cathode). The connection goes like this:

  1. Insert the LED into the breadboard.
  2. Connect the resistor in series to the LED's long leg (anode).
  3. Connect the other end of the resistor to the Arduino's digital pin 13.
  4. Connect the LED's short leg (cathode) to the Arduino's GND (ground) pin.

The resistor limits the current through the LED, so it should never be skipped.

2. Upload the code

Open the Arduino IDE, connect the board via USB and upload the following code. This code turns the LED on for one second and off for one second:

void setup() {
  pinMode(13, OUTPUT); // set pin 13 as an output
}

void loop() {
  digitalWrite(13, HIGH); // turn the LED on
  delay(1000);            // wait 1 second
  digitalWrite(13, LOW);  // turn the LED off
  delay(1000);            // wait 1 second
}

3. How does it work?

setup() runs once and configures pin 13 as an output. loop() then repeats forever: setting the pin HIGH puts 5 V on it and the LED lights; setting it LOW makes it 0 V and it turns off. The delay(1000) command pauses the program for 1000 milliseconds (1 second). If you like, you can lower this value to blink the LED faster.

Setting up the Arduino IDE

To upload the code, you need to install the free Arduino IDE on your computer. After installing, connect the board via USB and set two things in the IDE: choose your model (for example, Arduino Uno) from Tools → Board and the port the board is connected to from Tools → Port. If these two settings are wrong the code won't upload, and you'll usually get a "port not found" error. Once set correctly, you just press the "Upload" (arrow) button.

Calculating the right resistor for the LED

The resistor value isn't random; it's found with a simple calculation. By Ohm's law, resistance = (supply voltage − LED voltage) / LED current. For example, for a 5 V supply, an LED of ~2 V and a target current of 15 mA: (5 − 2) / 0.015 = 200 Ω. That's why 220 Ω is a common, safe choice. A larger resistor makes the LED dimmer; a smaller one makes it brighter but riskier.

Extend the project

Once the basics work, it's easy to grow the project. You can connect a few LEDs to different pins and light them in sequence for a "running light" effect, change the delay value to adjust the speed, or try controlling the LED with a button. The next big step is to use PWM with analogWrite to smoothly change the LED's brightness. Each addition reinforces a new fundamental concept.

Common mistakes

  • Skipping the resistor: an LED connected without one burns out quickly from excess current.
  • Inserting the LED backwards: an LED only works in one direction; if it doesn't light, flip its legs.
  • Wrong pin: the pin number in the code must match the physical connection.
  • Not setting board/port before uploading: if the correct board and port aren't selected in the IDE, the code won't upload.

Frequently asked questions

Which resistor value should I use?

For a 5 V supply and a standard LED, 220–330 Ω is a safe and common choice; the exact value is calculated from the LED's current and voltage ratings.

Can I do it with the board's built-in LED?

Yes; the Arduino Uno has a built-in LED connected to pin 13, so you can test this code without building an external circuit.

What's next?

You can try blinking multiple LEDs in sequence, controlling the LED with a button, or adjusting brightness with PWM.

Conclusion

Your first LED project is the best start for seeing how hardware and software work together. From here you can grow your projects with buttons, sensors and motors. To decide which board to continue with, see Arduino vs Raspberry Pi, and for the parts you need, check search.