Blink a Single External LED
This packet shows how to control a single external LED with an Arduino board.
The code for this packet is similar to the code for blinking the on-board LED. However,
the circuit is different.
Introduction to LEDs
LEDs come in many different types; for this packet, we’ll focus on monochrome LEDs, the most
common of which can produce light in red or green or yellow or blue.
Monochome LEDs have 2 leads; one is longer than the other. The longer lead is the “anode” or
positive lead. The shorter lead is the “cathode” or negative lead. When you get a new LED, both
leads are straight and it is easy to see which one is longer. Once an LED has been used, the
longer lead is often bent so that the two leads have the same top-to-bottom height, which is
convenient for connecting in breadboards. The bent lead will is still the anode, it’s just
harder to recognize.
|(New LED: leads are still straight)||(Used LED: longer lead has been bent)|
Introduction to resistors
A resistor can come in any one of many values from 1Ω to several MΩ. The value of any particular
resistor can (in principle) be red from the colors of the bands printed on it.
(However, it is difficult to remember the color code.) A 220Ω resistor has a these bands:
- a red band, indicating the resistance’s most significant digit is 2.
- a red band, indicating the resistance’s next most significant digit is also 2.
- a brown band, indicating the exponent of the resistor’s value is 2, so the resistor’s value is
2.20 × 10^2 = 2.20 × 100 = 220Ω.
- (usually) a gold band, indicating that its value is accurate to ±5%.
Resistors have 2 leads but no polarity so it doesn’t matter which side you connect to a component.
Connecting components directly 🙁
One way to connect the components is to:
- plug one lead of the LED into whichever I/O pin you’ll use on the Arduino,
- connect the other lead to one lead of the resistor, and
- connect the other lead of the resistor to one of the
GROUNDpins on the Arduino.
In order to have a good electrical contact between the LED and the resistor, you’ll
need to solder the LED to the resistor. This is time-consuming, requires extra equipment,
and makes it difficult for you to re-use the LED (or the resistor) in another circuit.
Connecting components via a breadboard 🙂
The solution is to use a “breadboard” which allows you to make temporary connections simply
by plugging components in to the “right” holes. The real electrical connections are made inside
|A “full-sized” breadboard|
To use the breadboard effectively, be aware of its basic layout:
- All of the holes along each edge of the board are connected together. Traditionally,
users connect a jumper cable from a hole near the blue line and one of the
on the Arduino board, and then connect all components in the circuit that need a
to that horizontal line of holes. When needed, users connect a jumper cable from a hole near the red
line to the
3V) pin on the Arduino board, and then connect all components requiring that
power to other holes near the red line.
|Two rows of “GND” connections||Two rows of “Power” connections|
- The 5 holes in each column (aka “field”) are connected together, but no field is
connected to any other field. Several separate fields are shown below:
|A single field in a breadboard|
- NONE of the holes on one side of the long divide parallel to the long edge of the board
are connected to ANY of the holes on its opposite side. The “great divide” is highlighted below:
|The great divide|
- Some breadboards have an additional (“mini”) divide in the middle of the board that
GNDrails on one side from the
GNDrails on the other side.
Such boards are electrically divided into 4 separate parts. They work as if you had 2 half-sized boards.
|The great divide and the mini-divide|