Skip to content

Make an LED blink

Your first Arduino project: make the built-in LED flash, understand the sketch, then change the timing to make it your own. No extra circuit needed.

  • Arduino
  • Beginner
  • 10 to 15 minutes
  • 6 steps

Before you start, you'll need

  • An Arduino UNO R3 with its built-in LED marked L. Other boards with a supported LED_BUILTIN can also run Blink; select the exact model in the IDE.
  • A USB data cable that fits your board and computer. UNO R3 uses USB-B; a charge-only cable will not upload code.
  • A Windows, macOS, or Linux computer with Arduino IDE installed. Allow extra time if you are installing it for the first time.
  • No breadboard, loose LED, resistor, or battery is needed for this built-in LED project.
Need to install Arduino IDE? Start with the Arduino setup guide.

Connect your Arduino

About 1 minute

Give the board power and a way to receive your code.

  1. Start with the board by itself. Disconnect any breadboard circuits or shields before this first test.
  2. Connect the Arduino to your computer using the data USB cable, then open Arduino IDE.
  3. Find the LED marked L on the UNO. This is the light your sketch will control; the ON power light is different.

You should see

The board's power light is on. The L LED may already blink because a sketch was previously loaded; that is okay.

It didn't work
  • No lights appear on the board.

    Check both cable connections. Try another USB port or a known working cable, with the board connected directly to the computer.

Select your board and port

About 2 minutes

Tell the IDE what you are programming and where it is connected.

  1. In IDE 2, open the board selector near the top of the window. Select the connected board and its port. If it says Unknown, choose Select other board and port and select the model yourself.
  2. For UNO R3, select Arduino Uno from the Arduino AVR Boards package. Install the package if the IDE asks. An UNO R4 needs its own UNO R4 package and model selection.
  3. You can also make these choices through Tools → Board and Tools → Port. Select the port that appears when you connect your Arduino.

You should see

The IDE shows your board model and a selected port. The port name varies by computer; you do not need a specific COM number.

It didn't work
  • The board has power, but no port appears.

    A power light does not prove the cable carries data. Try a known data cable and a direct USB port. Unplug and reconnect the board, then reopen the selector.

  • My board is not an UNO R3.

    Use the complete model name printed on your board. Do not choose Arduino Uno for an UNO R4 or a different Nano model. Check that model's documentation for its package and built-in LED.

See what the code does

About 2 minutes

Follow one repeating instruction: light on, wait, light off, wait.

  1. setup() runs once at startup. pinMode(LED_BUILTIN, OUTPUT) prepares the board's LED pin to be controlled by your program.
  2. loop() repeats while the board runs. For the UNO used here, digitalWrite(..., HIGH) turns the L LED on and digitalWrite(..., LOW) turns it off.
  3. delay(1000) pauses for 1,000 milliseconds, or one second. With one wait after on and another after off, a complete cycle lasts about two seconds.
  4. LED_BUILTIN uses the LED pin defined for the board selected in the IDE. On UNO R3, this is digital pin 13. Keep the constant rather than guessing another board's pin number.
Arduino C++ · Blink.ino
// Based on Arduino's public-domain Blink example.
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Copy the complete sketch into Arduino IDE, replacing any existing setup() and loop() functions. No extra library is needed.

You should see

You can point to the line that switches the LED on, the line that switches it off, and the two waits in between.

Upload and watch it blink

About 2 minutes

Send the sketch to your Arduino and see a physical result.

  1. Click Verify (the checkmark) to check that the sketch compiles. If it reports an error, fix it before continuing.
  2. Click Upload (the right arrow). Leave the board connected and wait for the upload to finish.
  3. Watch the L LED: it should stay on for about one second, then off for about one second, and repeat. The ON power light stays lit.

You should see

The IDE reports a successful upload, and the L LED repeats the on/off pattern. If it was already blinking, the timing change in the next step will prove your edit reached the board.

It didn't work
  • The sketch does not compile.

    If you pasted the code, replace the entire sketch with the complete example above. Keep the braces and semicolons, and make sure there is only one setup() and one loop().

  • It verifies, but will not upload.

    Recheck the exact board and port, then close other programs using the port, including another Serial Monitor. Try a direct USB connection with a known data cable. Use the full error message with Arduino's upload support guide linked below.

  • Upload succeeds, but I do not see the LED flash.

    On UNO, watch L rather than ON or the RX/TX lights. For another board, confirm it has a supported built-in LED and that the correct board model is selected.

Make the timing your own

About 2 minutes

Change the pattern and prove that you control what happens.

  1. Change both delay(1000) lines to delay(500), then upload again. The LED now spends half a second on and half a second off.
  2. Try a short flash: use delay(100) after HIGH and delay(900) after LOW. Upload and compare the pattern.
  3. Choose your own pair of values. Predict how the LED will behave, upload the change, then check your prediction.
  4. When you are done, restore both delays to 1000 if you want the original pattern. Save your sketch so you can return to it.

You should see

Each successful upload changes the timing as you predicted. You have connected the board, edited a sketch, and made your code control a real output.

It didn't work
  • The timing has not changed.

    Verify alone does not update the board. Upload your edited sketch and wait for success. Check that you changed both delays when you want both halves of the cycle to change.

What to do next

Stuck? Contact Vilros Support with your board model and what you see on screen.

Project references

Adapted from the original example, with setup help from the official documentation below.