Tutorial 2: Controlling Digital Outputs
English Chinese (Simplified) Czech French German Hindi Italian Japanese Korean Russian Spanish

In this tutorial, we will show you how to use the UNO R3 Plus digital output signals to control an array of LEDs.  We will show to how to wire up a simple LED circuit using a breadboard and how to correctly size the resistor for the LED circuit.

I – Stuffs that you will need:

You will need a UNO R3 Plus board, a mini USB to standard USB cable, a PC as well as a breadboard, LEDs, resistors and jumper cables for assembling your LED circuit.





Mini USB to Standard USB


Windows PC











Jumper Cables




II – Background Information:

The digital pins on the UNO R3 Plus are rated at 5V.  This means when it drives a logic-1, you will measure a 5V on the pin, and when it drives a logic-0, you will measure 0V.  This also means you can apply a signal as high as 5V signal to it without damaging it.  The UNO R3 Plus has 14 digital pins that can be configured as input or output.

In this tutorial, we will configure 4 digital pins as output and use it to light up four LEDs one at a time.   An LED stands for light emitting diode emits light when an electrical current is flowing through it.  When connecting the LED to the UNO R3 plus board, we will need to put a resistor in series to limit the amount of electrical current flowing through it.  If you put in a resistor with a very large resistance, the amount of current flowing through will be very small, and the LED will not light up very bright.  If you put in a resistor with a very small resistor (or not putting in a resistor), the amount of current flowing through the LED will be very high and you could blow out the LED.

To size the resistor, you will need to look at the LED data sheet and find out how much current (If) it can tolerate and what is its forward voltage (Vf).   Typically, a small signal diode will be able to handle up to 20mA of forward current and a voltage drop of 2V.   Knowing this, we can use ohm’s law to determine the size of the resistor we should use.

We know that the UNO R3 Plus will output a 5V when it is at logic 1, we can use this equation to find out the minimum resistor value:

V = I x R

R = V / I

R = (5V – Vf) / I = (5V – 2V) / 20 mA  = 150 ohm

150 ohm is the smallest resistor we can use without damaging the LED.

Question:  If we use a 330ohm resistor, what will be the current?


III – Schematic Diagram:

Below is the schematic diagram, we will connect a 330 ohm resistor in series to each LED device.  We will use digital pin 2, 3 4 and 5.

IV – Wiring the Breadboard:

Let’s wire up the breadboard. The lead of the positive terminal of the LED is longer than the negative terminal.  Be sure to wire the positive terminal to the resistor and the negative terminal to ground.


V – Writing the Sketch:

Start a new project and copy and paste the below sketch into the Arduino environment.  This sketch will setup digital pin 2, 3, 4, and 5 as output using the pinMode function and will toggle each pin one at a time using the digitalWrite function.




Once the sketch is loaded onto the UNO R3 Plus, you should see each of the LED light up one at a time.  From white, yellow, green, red, and then back to white.


Things we have covered in this tutorial:

  • Digital output pin
  • How to size a resistor when driving an LED


Tutorial 3: Using Digital Input

Tutorial 4: An LED Game

Tutorial 5: Building Voltage Meter

Tutorial 6: Using Buzzer to Play a Melody

Tutorial 7: Counting Down with a 7 Segment LED

Tutorial 8: Powering the UNO R3 PLUS Using Batteries


Download  ARD-101_Tutorial_Codes