---
# System prepended metadata

title: 'Getting Started with Arduino: Blink an LED'
tags: [Arduino]

---

![cc9583a3-f8ce-4fa7-b8cc-0d3cc07d44e5](https://hackmd.io/_uploads/HJhZHdiyeg.jpg)

**What You'll Need**

* [Arduino board](https://www.ampheo.com/c/development-board-arduino) (Uno, Nano, etc.)
* USB cable
* LED (any color)
* 220Ω resistor (or similar value)
* Breadboard
* Jumper wires

**Basic Setup**
1. Install Arduino IDE
Download from arduino.cc and install for your operating system.
2. Connect Arduino to Computer
Plug in your Arduino using the USB cable. The power LED should light up.

**Building the Circuit**
LED Connection:
```
Arduino Pin 13 → Resistor → LED Longer Leg (Anode)
LED Shorter Leg (Cathode) → Arduino GND
```

Important: Always use a current-limiting resistor (typically 220Ω-1kΩ) to protect the LED.

**Writing Your First Program**
Open the Arduino IDE and enter this code:
```
arduino
void setup() {
  // Initialize digital pin 13 as output
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);   // Turn LED on
  delay(1000);              // Wait 1 second
  digitalWrite(13, LOW);    // Turn LED off
  delay(1000);              // Wait 1 second
}
```

**Uploading the Code**

1. Select your board: Tools → Board → "[Arduino Uno](https://www.ampheo.com/product/a000046-25542493)" (or your model)
2. Select port: Tools → Port → (choose the correct COM/USB port)
3. Click the Upload button (right arrow icon)

**Understanding the Code**
setup(): Runs once when the Arduino starts

pinMode(13, OUTPUT): Configures pin 13 as output

loop(): Runs continuously after setup

* digitalWrite(13, HIGH): Sets pin 13 to +5V (turns LED on)
* delay(1000): Pauses for 1000ms (1 second)

**Modifying the Blink Pattern**
Try changing the delay times:

```
arduino
void loop() {
  digitalWrite(13, HIGH);
  delay(200);    // Shorter on-time
  digitalWrite(13, LOW);
  delay(800);    // Longer off-time
}
```

**Using a Different Pin**
To use another pin (like pin 8):

1. Change the circuit to use pin 8 instead of 13
2. Modify the code:

```
arduino
void setup() {
  pinMode(8, OUTPUT);  // Changed to pin 8
}

void loop() {
  digitalWrite(8, HIGH);
  delay(500);
  digitalWrite(8, LOW);
  delay(500);
}
```

**Troubleshooting**
If the LED doesn't light up:

1. Check all connections are secure
2. Verify LED orientation (long leg to +, short to -)
3. Ensure correct pin number in code matches circuit
4. Try a different LED or resistor
5. Check Arduino's power LED is on

**Next Steps**
Once you've mastered blinking:

1. Try multiple LEDs
2. Experiment with different blink patterns
3. Learn about analogWrite() for brightness control
4. Add a button to control the LED

This simple project teaches you the fundamentals of [Arduino](https://www.ampheoelec.de/c/development-board-arduino) programming and electronics - the foundation for all future Arduino projects!