Everyone’s experience with microcontrollers has to start from somewhere, which is why we’ve created this guide to help you write and test your first program, in the form of a blinking LED. Most Arduino boards include a built-in LED, but here we’ll use an external one to get you comfortable with components. We’ll write the program in C++, so this works for any Arduino or compatible microcontroller.
What you need
- Arduino (we’ll be using an Arduino Uno)
- 1x 5mm LED
- 220 ohm resistor
- Breadboard
- Jumper wires
- USB Cable
- PC with Arduino IDE installed
If you don’t have the Arduino IDE yet, download it from Arduino Software.
Understanding the components
- How it Works: LEDs are diodes, meaning current flows one way only—from anode (+) to cathode (–).
-
Polarity Matters:
- Long leg (Anode, +): Connects to the positive side (your Arduino pin).
- Short leg (Cathode, –): Connects to ground (GND). Look for a flat edge on the LED body to confirm.
- Voltage Drop: A typical 5mm LED needs ~2V to light up. Your Arduino outputs 5V, so we need to “drop” the extra voltage safely.
- Why user Resistors: Without it, your LED could draw too much current (up to 20mA max for safety), overheating and burning out in seconds
- The 220 Ω resistor acts as a limiter, dropping voltage and restricting current to ~10–15mA, bright enough without the fireworks.
- Rule of Thumb: 220–1,000 Ω works for most LEDs. Higher = dimmer; lower = brighter (but riskier). This can be calculate with Ohm’s LawL R = (V_supply - V_LED) / I_max.
Wiring the LED
- Place the LED on the breadboard
- Connect the long leg to Arduino digital pin 13 through the 220 ohm resistor
- Connect the short leg to GND on the Arduino
Pin 13 has a built-in LED on most Arduino boards, but using an external LED helps you practice component wiring.
Selecting the board and port
-
Open Arduino IDE
-
Go to Tools, Board, Board Manager. Search for and install Arduino AVR Boards by Arduino if needed
-
Back in Tools, Board, select the correct board (Arduino Uno for this guide)
- Go to Tools, Port, and select the port your Arduino is connected to. On Windows, this shows as COM followed by a number, which you can verify in Device Manager
Writing and understanding the code
void setup() { pinMode(5, OUTPUT); } void loop() { digitalWrite(5, HIGH); delay(500); digitalWrite(5, LOW); delay(500); }
Code explanation:
-
void setup() runs once when the Arduino powers on or resets. pinMode(13, OUTPUT) sets digital pin 13 as an output, meaning we can send voltage to it.
- void loop() runs repeatedly. digitalWrite(13, HIGH) turns the LED on by applying voltage. delay(500) pauses the program for 500 milliseconds. digitalWrite(13, LOW) turns the LED off. Another delay(500) pauses again, creating the blinking effect.
Uploading the code
- Connect your Arduino to your PC via USB
-
Make sure the correct board and port are selected - the correct port number can be found in device manager under Ports

- Click Upload
-
The LED should start blinking with half-second intervals
If it doesn’t blink, check the LED orientation, resistor connection, and that the port in Arduino IDE matches your board.
Blinking an LED is the perfect first step in your Arduino journey and sets the foundation for more advanced projects like sensors, displays, and automation.