Sub topic 8
Building the circuit on a breadboard
Assume you know what voltage, current, and resistance mean, and that you have an Arduino-compatible board, a USB cable, a breadboard, an LED, jumper wires, and a resistor. This chapter focuses on wiring an external LED to digital pin 8. The board must already run the Arduino IDE, and you should know how to upload a sketch.
A breadboard lets you build a circuit without soldering. Its holes are connected underneath in groups. On a typical breadboard, five holes in one numbered row are electrically connected. The five holes on the other side of the center gap form a separate group. The center gap prevents a component such as an integrated circuit from shorting its two sides together.
Many breadboards also have long power rails marked with + and -. Holes along one rail are usually connected, but some rails are split in the middle. Check the markings or use a continuity tester if you are unsure.
Parts and connections
Use one resistor in series with the LED. Series means that current must pass through the resistor and then through the LED before reaching ground.
| Part | Connection | Purpose |
|---|---|---|
| Arduino digital pin 8 | One end of the resistor | Supplies the HIGH or LOW signal |
| 330 Ω resistor | Between pin 8 and the LED anode | Limits current |
| LED anode | To the resistor | Positive LED terminal |
| LED cathode | To Arduino GND | Completes the circuit |
| Arduino GND | To the LED cathode | Provides the return path |
The word GND means ground. In this circuit, it is the reference point and the return path for current. Connect the Arduino's GND pin directly to the breadboard row containing the LED cathode. Do not assume that a breadboard's negative rail is connected to Arduino GND. Add a jumper wire if needed.
Place the LED correctly
An LED is polarized. A polarized component works only when current enters and leaves it in the correct direction.
The anode is the positive terminal. The cathode is the negative terminal. On many through-hole LEDs:
- The longer leg is the anode.
- The shorter leg is the cathode.
- The flat edge on the LED body marks the cathode.
- The larger internal metal shape usually marks the cathode.
These clues are useful, but inspect the specific LED when possible. If the LED is reversed, it normally will not light. Reversing it does not usually damage it at the small voltage used here, but it prevents the circuit from working.
Insert the LED so its two legs are in different connected groups. If both legs share one five-hole group, the breadboard connects them directly, bypassing the LED circuit. Place the resistor in a separate row from the LED anode, with its other leg sharing the anode's row. Connect a jumper from the resistor's free end to pin 8. Connect the cathode's row to GND.
Check the resistor
An LED should not connect directly between an Arduino output and ground. When the output is HIGH, the LED can draw more current than the pin or LED can safely handle. The resistor limits that current.
Use the approximate resistor equation:
R = (V_supply - V_forward) / I_target
For a 5 V Arduino, a red LED with a forward voltage of about 2 V, and a target current of 10 mA:
R = (5 V - 2 V) / 0.010 A = 300 Ω
Choose the next common value above this result, such as 330 Ω. A larger resistor makes the LED dimmer but reduces current. A 1 kΩ resistor is also a safe starting value and will usually produce visible light.
Test the wiring with a sketch
This sketch configures pin 8 as an output and alternates its voltage between HIGH and LOW. When pin 8 is HIGH, current flows through the resistor and LED. When it is LOW, there is little voltage across the LED, so it turns off.
const uint8_t LED_PIN = 8;
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
delay(500);
}Disconnect USB power before moving wires. Then compare every wire with the connection table. Check that the LED legs are in separate breadboard groups, the resistor is actually in series, and the Arduino ground is connected to the cathode. If the LED remains dark, reverse the LED first. If it stays on continuously, look for a misplaced jumper or a short circuit between pin 8 and 5 V.
Exercise
You have a 5 V supply, a green LED with an estimated 2.2 V forward voltage, and a target current of 8 mA. What resistor value should you calculate, and which common value would be a sensible choice?
Show answer
Calculate R = (5 - 2.2) / 0.008 = 350 Ω. Choose a common value at or above this result, such as 390 Ω.