Set up the Arduino IDE and blink an LED

Install the Arduino IDE, upload your first sketch to the UNO R3 and make an LED blink on a breadboard.
  • Level:Beginner
  • Duration: 30 min
  • Ages 10+
  • Platform: Arduino

What you'll need

Set up the Arduino IDE and blink an LED – EEMENTOR STEM lesson

Every electronics journey starts with a blinking LED. In this lesson you install the Arduino IDE, connect your UNO R3 board and upload your first program, called a sketch.

What you'll learn

  • How to install the Arduino IDE and select your board
  • The structure of an Arduino sketch: setup() and loop()
  • How to wire an LED safely with a resistor on a breadboard

What you need

  • UNO R3 board and USB cable
  • Breadboard
  • 1 LED (any colour)
  • 1 resistor, 220 Ω
  • 2 jumper wires

Step 1: Install the Arduino IDE

  1. Download the Arduino IDE from arduino.cc/en/software and install it.
  2. Connect the UNO R3 to your computer with the USB cable. The green power LED on the board lights up.
  3. In the IDE, open Tools → Board and choose Arduino Uno.
  4. Open Tools → Port and choose the port that appeared when you plugged in the board (for example COM3 on Windows or /dev/cu.usbserial… on a Mac).

If no port appears, your board may use a CH340 USB chip. Install the CH340 driver for your operating system, then reconnect the board.

Step 2: Wire the LED

An LED has a long leg (the positive anode) and a short leg (the negative cathode). The resistor limits the current so the LED and the board pin aren't damaged.

Breadboard wiring diagram: Set up the Arduino IDE and blink an LED
Breadboard view. Check each connection against the wiring table below.
From To
UNO pin 8 Resistor, then the LED's long leg
LED short leg UNO GND

Step 3: Upload the sketch

const int LED_PIN = 8;

void setup() {
  pinMode(LED_PIN, OUTPUT);   // pin 8 drives the LED
}

void loop() {
  digitalWrite(LED_PIN, HIGH); // LED on
  delay(500);                  // wait half a second
  digitalWrite(LED_PIN, LOW);  // LED off
  delay(500);
}

Click Upload (the right arrow). After a few seconds the IDE says "Done uploading" and your LED starts blinking.

How it works

setup() runs once when the board starts. loop() then runs again and again, forever. digitalWrite() switches the pin between 5 V (HIGH) and 0 V (LOW), and delay() pauses for a number of milliseconds.

Try this next

  • Change both delays to 100 to make the LED blink fast.
  • Add a second LED on pin 9 and make the two LEDs blink in turn, like a railway crossing.

Troubleshooting

  • Upload fails: check that the right board and port are selected under Tools.
  • LED stays off: turn the LED around. It only conducts in one direction.

Build it yourself

Everything used in this lesson comes in one kit, with parts tested by our engineers.

UNO R3 Starter Kit | Arduino IDE Compatible | Free Tutorials $48.00

Shop the kit