# Driving an external LED

## Theory

A light emitting diode (LED) must have its electric current regulated, otherwise it will be damaged. However, the Arduino lacks a current limited output. Instead, we use a resistor to provide current limiting.

## Wiring

The images below are two views of the same circuit. The schematic illustrates the design conceptually, whereas the breadboard layout shows how to implement it.

Here, pin 3 (also called digital 3 or D3) is connected to the LED. When D3 is driven high (5 volts), current will flow through the LED and into the ground (GND) pin.

Build this circuit on your breadboard. Note that a LED will not operate if you connect it backwards. Figure out the correct orientation by looking carefully at the LED casing. It is not perfectly round; one side is be flattened off. The flat edge on the case corresponds to the bar in the schematic symbol. Connect the flat edge to the lower voltage side of the circuit.

## Exercise

Adjust your code from the previous lesson so that the blinking sequence is shown on the external LED.

Save your work as lesson3. Each lesson should be saved into a separate file.

## Topics for workshop discussion

Why 150 Ω? How to choose the resistance?

• The voltage across a LED is approximately independent of the current that flows. If you have a red LED, that voltage is approximately 1.8 volts.
• Given that the Arduino supply is 5 V, and 1.8 V is taken across the LED, this means the voltage across the resistor must be 5 – 1.8 = 3.2 V.
• If we know the resistor voltage and the resistance, we can solve for the current using Ohm’s law (V = IR).
• Changing the resistance will adjust the current that flows in the LED. The LED current is proportional to its brightness.