All articles

    Your First Arduino Project: Blink, Step by Step

    A first Arduino project guide for beginners: a tour of the Uno board, installing the Arduino IDE, choosing the board and port, understanding setup and loop, variables and comments, uploading the Blink code, wiring an external LED with a resistor, a first message on Serial, a traffic light exercise, rules so you don't damage the board, and solving common upload problems.

    Updated 5 min read

    Every Arduino journey starts with the same project: a blinking LED. It's simple, but it teaches you the whole cycle: write code, upload it, and see the result. Once it works, you're ready for anything after it.

    A quick tour of the board

    PartWhat it does
    USB socketUploading, power and Serial
    Adapter socketPower from 7 to 12 V
    Pins 0 to 13Digital input and output, with PWM on those marked ~
    A0 to A5Analog inputs (they also work as digital)
    5V, 3.3V and GNDPower for external parts
    Reset buttonRestarts the program from the beginning
    ON, L, TX and RX LEDsPower, pin 13, and communication

    1. Getting set up

    1. Download the Arduino IDE from the official Arduino site and install it.
    2. Connect the board to the computer with a USB cable that carries data, not just a charging cable. That's a well-known mistake!
    3. From the Tools menu:
    4. Board: choose Arduino Uno (or whichever board you have).
    5. Port: choose the port that appeared when you plugged in the board (COM3, for example, on Windows).

    The port doesn't appear? Cheap clone boards usually have a CH340 chip, which needs its driver installing.

    Not sure which port? Unplug the board and look at the menu, then plug it back in: the port that newly appears is the board's.

    2. The code

    void setup() {
      pinMode(13, OUTPUT);
    }
    
    void loop() {
      digitalWrite(13, HIGH);
      delay(1000);
      digitalWrite(13, LOW);
      delay(1000);
    }
    The LED on the board (L) is connected to pin 13, and switches on and off every second
    The LED on the board (L) is connected to pin 13, and switches on and off every second
    • setup(): runs once at the start. Here we say that pin 13 is an output.
    • loop(): repeats forever. On, wait a second, off, wait a second.
    • delay(1000): wait 1000 ms.

    This code is ready-made under File → Examples → 01.Basics → Blink, so if you want to check the board works before anything else, open it and upload it.

    The same code, tidier

    const int LED = 13;   // a name instead of a number: change the pin here only
    
    void setup() {
      pinMode(LED, OUTPUT);
    }
    
    void loop() {
      digitalWrite(LED, HIGH);   // on
      delay(500);
      digitalWrite(LED, LOW);    // off
      delay(500);
    }

    Anything after // is a comment: the computer ignores it, and it's there for you to understand the code a month later. And every statement ends with ;, which is the most common typing mistake.

    3. Uploading

    Press the Upload button (the arrow). You'll see the TX and RX LEDs flicker, then the message "Done uploading". And now the small L LED on the board blinks every second. Congratulations! 🎉

    The Verify button (the tick) compiles the code and checks for errors without uploading. If there's a mistake, it appears in red at the bottom with its line number.

    4. An external LED

    Now try a real LED on a breadboard:

    • Pin 13 → a 220 Ω resistor → the LED's long leg (the anode).
    • The short leg (the cathode) → GND.

    Why the resistor? Without it, the LED draws too much current and burns out, or harms the Arduino pin. The calculation is in the LED resistor article.

    5. The board talks to you

    Add these two lines, and open the Serial Monitor (the magnifier at the top right) at 9600:

    void setup() {
      Serial.begin(9600);
      Serial.println("Hello from Arduino!");
    }

    That's the first step in the most important skill: making the board tell you what it's doing. Continue with the Serial Monitor article.

    Try changing things

    • Change 1000 to 200 → the blinking gets faster.
    • Use another pin, such as 9, and change the number in the code.
    • On a pin marked ~, try analogWrite(9, 50) for a dim glow, which is the idea behind PWM.

    Exercise: a traffic light

    3 LEDs (red, yellow and green) on pins 10, 11 and 12, each with a resistor. Write the code: green for 5 seconds, yellow for 2, red for 5, and repeat. Once it works, see how to do it without delay in millis instead of delay.

    Rules so you don't damage the board

    • An Arduino pin safely carries about 20 mA. Anything bigger (a motor, an LED strip, a relay) needs a transistor or MOSFET.
    • Don't connect 5V to GND directly.
    • Don't feed more than 5 V into any pin.
    • Disconnect the power before changing the wiring on the breadboard.

    Common upload problems

    ProblemFix
    The port doesn't appearA data cable, and the CH340 driver
    avrdude: not in syncChoose the right board and port, and remove anything connected to pins 0 and 1
    The code doesn't upload and there's no messageTry another USB port
    expected ';' before ...A missing ; at the end of the line before that number
    'xxx' was not declaredA misspelt name, or a capital letter (Arduino distinguishes A and a)
    Port busyThe Serial Monitor or another program has the port open

    The next step

    Read a button with a pull-up, then try a sensor. And if you want to learn in an organised way with support, that's what we do in the courses.

    FAQ

    Does the board forget the code when I unplug it? No, the code is stored in flash. As soon as you connect it to any power source, it runs by itself without a computer.

    A genuine Uno or a clone? A cheap clone runs the same code, and the difference is usually just the USB chip (CH340). It's perfectly good for learning.

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.