Tutorial 3: Starting with Arduino

Created on: 31 July 2012
Updated on: 13 January 2023

How to start using an Arduino for beginners in electronics. In this tutorial, you will first load a program, known as an Arduino sketch, to an Arduino Uno board. The sketch flashes or blinks the on-board LED on and off. You will then connect an external LED to the Arduino using a breadboard and load a new program or sketch to flash the external LED on and off.

You will learn:

  • How to set up and program the Arduino.
  • How to interface (connect) an LED to the Arduino.

This video shows what you will achieve:

Prerequisites for Starting with Arduino

First complete tutorial 1 before attempting this tutorial. Although not essential, it is also recommended to complete tutorial 2.


The following components are needed when connecting an external LED to the Arduino Uno board.

Qty Part Designator Notes Type
1 470 ohm resistor (yellow - violet - brown) R1 1/4W, 5% or better Resistors
1 5mm red LED D1 Other colored and sized LEDs could also be used, e.g. 3mm green LED Semiconductors

You will also need:

  1. A breadboard
  2. Breadboard wire links
  3. An Arduino Uno board or Arduino Uno compatible board
  4. Standard USB cable
Parts needed for this starting with Arduino tutorial: a breadboard, USB cable, Arduino Uno, resistor, LED and wire links
Parts Needed for this Starting with Arduino Tutorial

Installing the Arduino Software

You basically just need to download and install the Arduino IDE software for the operating system that you are using. To do this, refer to the Getting Started with Arduino web page – click the Windows, Mac or Linux link on this page, or find the direct links below.

Windows: Windows Arduino IDE installation page.

Linux: Linux Arduino IDE installation page.

Mac OS: MacOS Arduino IDE installation page.

Programming the Arduino

We will initially program the Arduino board with a program that is built into the Arduino IDE. This program flashes the on-board LED on and off.

Plug in the Arduino Board and Open the Blink Sketch

  1. Plug the USB cable into the Arduino Uno USB connector and the other end into a spare USB port on the PC that you loaded the Arduino IDE to.
  2. Start the Arduino IDE.
  3. Make sure that you have selected the correct board and serial port as described in the installation instructions.
  4. On the top menu bar, click File → Examples → 1.Basics → Blink
  5. A new window opens showing some program code, as seen in the image below.
Arduino IDE with the Blink program open
Arduino IDE with the Blink Program Open

Load the Sketch to the Arduino

  1. Click the Upload button (shown circled in red below) on the top toolbar to load the program to the Arduino Uno board.
  2. The program should load and then start running – you will see the LED marked 'L' on the board start to flash on and off.
Arduino IDE upload button
The Arduino IDE Upload Button

Arduino LED Circuit Diagram for Beginners

We will now interface an external LED to the Arduino board. Interface simply means to connect the LED to an Arduino pin. This is done by connecting an LED and series resistor between pin 2 of the Arduino Uno and an Arduino GND pin, as described next.

The circuit diagram below tells us to connect the anode of the LED to pin 2 of the Arduino board. Pin 2 is marked on the silk-screen of the board. The LED cathode connects to a resistor and the other lead of the resistor connects to one of the GND pins of the Arduino (the Arduino Uno has three pins marked as GND, use any one of them).

Circuit diagram for beginners: An LED interfaced to an Arduino Uno
Arduino LED Circuit Diagram for Beginners

Building the Arduino LED Circuit

Build the Arduino LED circuit on a breadboard using the components described near the top of this page, and shown in the circuit diagram. This is a very simple circuit for beginners. Also refer to the images that follow when following the build instructions below.

1. Insert the LED into the Breadboard

Bend the longer lead of the LED out and down and then plug the LED into the breadboard across the middle insulating channel of the breadboard. See the images below.

2. Connect the 470Ω Resistor to the Circuit

Plug the 470 ohm resistor into the breadboard so that one of its leads connects to the cathode (shorter lead) of the LED. Connect the other lead of the resistor to one of the GND pins of the Arduino board using a long wire link.

3. Wire the LED to the Arduino Uno Board

Connect the anode (longer lead) of the LED to pin 2 of the Arduino using a long wire link.

The following images show two ways of building the same circuit on breadboard. One shows how the circuit was built that features in the video at the top of this page. The other circuit is wired according to the photo that follows.

Arduino LED interface circuit on breadboard
Arduino LED Interface Circuit on Breadboard
Arduino LED interface circuit alternate wiring
Arduino LED Interface Circuit Alternate Wiring

Your circuit should now look something like this if you used the alternate wiring image above:

LED interface circuit on breadboard
LED Connected to the Arduino on Breadboard

Load a New Program or Sketch to an Arduino

The new program that follows is an adaptation of the previous program. It has been modified to flash an LED on and off that is connected to pin 2 of the Arduino, as in our circuit diagram above.

In Arduino terminology, a software program is referred to as a sketch.

Create a New Arduino Sketch in the IDE

Start the Arduino IDE. If an existing sketch is open in the IDE, then select File → New Sketch from the top IDE menu. This opens a new blank sketch that contains a few basic lines of code. Either type the following program (from the screen-capture below, or from the listing that follows) into the IDE and save it, or select the code from the listing below and then copy it and paste it into the IDE. If copying and pasting, first remove the existing lines of code from the new sketch.

LED2 blink program
The LED2_blink Program

The LED2_blink Program: Copy the following Block of Code and Paste it into the Arduino IDE

void setup() {                
    // set pin 2 as an output
    pinMode(2, OUTPUT);     

void loop() {
    digitalWrite(2, HIGH);  // switch LED on 
    delay(1000);            // keep LED on for 1s
    digitalWrite(2, LOW);   // switch LED off
    delay(1000);            // keep LED off for 1s

Save the New Sketch

After either typing or pasting the code into a new sketch in the Arduino IDE, save it using File → Save from the top IDE menu. Name the new sketch LED2_blink when prompted.

Verify the Program

Click the Verify button on the top toolbar of the IDE to make sure that the program has no errors in it (the verify button is the first icon on the toolbar – the tick mark).

If the program has any errors, then make sure that you typed the program in exactly as shown. Make corrections, save and verify again.

Upload the Program

Click the Upload button to load the program to the Arduino board.

After the upload completes, the external LED interfaced to pin 2 of the Arduino board should start to flash on and off just like the on-board LED did after loading the first program.