Sub topic 8
Building the circuit on a breadboard
This chapter assumes you have read the previous two chapters. You know which LED leg is the anode and which is the cathode, and you can size a series resistor with Ohm's law. You also need a board, a USB cable, a breadboard, one LED, one resistor of about 220 Ω, and two jumper wires. Here you turn those parts into a working circuit. The next chapter runs the blink sketch on it.
What a breadboard is
A breadboard is a plastic block with a grid of small holes. Behind the holes are spring-loaded metal strips that grip a component leg or a wire when you push it in. Nothing is soldered, so you can rebuild a circuit as often as you like.
The strips are the whole point. Two parts connect electrically only if their legs sit in holes joined by the same strip. Almost every wiring mistake on a breadboard comes down to putting a leg in a hole whose strip goes somewhere you did not intend.
The two kinds of strip
A standard breadboard has two regions.
- The terminal strip area is the large central block. It is laid out in numbered columns, and each column has two halves, usually labelled a to e and f to j. The five holes in one half of a column are connected. The two halves of the same column are not connected, because a gap called the center channel separates them.
- The power rails are the long strips running along the top and bottom edges, often marked with a red line (+) and a blue or black line (−). All holes along one rail are connected.
The names vary between manufacturers, so this chapter calls the numbered groups of five holes "rows", whichever way your board is turned. What matters is which holes are joined.
| Region | What is connected | Typical use |
|---|---|---|
| Five holes in one half of a numbered column | Those five holes only | Joining the legs of two or more components |
| Two halves of the same column | Not connected | Placing a chip so its two sides stay separate |
| A power rail | Every hole along its length | Distributing GND or a supply voltage |
Gotcha: split power rails
On some full-size breadboards the power rail is broken in the middle. The left half and right half are separate strips, so a wire at one end does not reach the other end. If a component on the far side of the board gets no power, check the rail for a gap. A short jumper across the break fixes it. Check this if your breadboard has a visible gap or a break in the printed line.
Plan the circuit before you place parts
The electrical path is the same as in your calculation. Current leaves a digital pin, passes through the resistor and then the LED, and returns to GND on the board.
Two points about this path matter on the breadboard.
- The resistor and the LED are in series, so exactly one wire's worth of current flows through both. Each junction between two parts is a place where two legs must share a strip.
- The resistor can go in either orientation. It has no polarity. The LED must go in the correct orientation, with the anode on the pin side.
If you are using a 3.3 V board, the supply voltage in your resistor calculation is 3.3 V, not 5 V. A 220 Ω resistor still works for a standard red LED, but the LED will be dimmer.
For this build, use these connections.
| From | To | Purpose |
|---|---|---|
| Board pin 8 | Row 10, via jumper wire | Signal from the board |
| Row 10 | Resistor leg 1 | Signal enters the resistor |
| Resistor leg 2 | Row 14 | Resistor output meets the LED |
| Row 14 | LED anode | Current enters the LED |
| LED cathode (row 15) | GND rail, via a short wire | Return path |
| GND rail | Board GND pin, via jumper wire | Shared ground |
The row numbers are arbitrary. Choose any free columns, as long as the resistor's second leg and the LED's anode share a strip and no other part does.
Step-by-step build
Disconnect the USB cable before you start. Wiring a live board risks an accidental short between a pin and GND while you push wires in. A brief short on a pin can damage it.
- Connect the ground rail. Push one end of a jumper wire into a hole on the blue (−) rail. Push the other end into a GND socket on the board. This single wire makes the whole rail a GND connection point, which you will reuse in later projects.
- Place the resistor. Insert one leg in row 10 and the other in row 14. The body spans the gap between them. Rows 10 and 14 are on the same side of the center channel, so use holes a to e in both.
- Place the LED. Insert the long leg (anode) in row 14, in the same strip as the resistor's second leg. Insert the short leg (cathode) in row 15, a neighbouring strip. If the leads are the same length because someone trimmed them, look at the LED body. The cathode side has a flat edge.
- Return to GND. Push a short wire from row 15 to a hole on the GND rail.
- Connect the signal. Push a jumper from board pin 8 to row 10.
- Check the layout visually, then connect USB.
Resulting layout, with the part in each strip:
| Strip | Contents |
|---|---|
| Row 10 | Jumper from pin 8, resistor leg 1 |
| Row 14 | Resistor leg 2, LED anode |
| Row 15 | LED cathode, wire to GND rail |
| GND rail | Wire from row 15, jumper to board GND |
Each of the four strips holds exactly the legs listed. That is the check to run on any breadboard circuit: for every strip, list what shares it, and compare against your plan.
Placing parts so they stay put
- Push legs straight down until they stop. A leg that sits halfway in makes an intermittent connection that looks like a software bug.
- Avoid bending LED legs sharply close to the body. If the legs are too long for your spacing, bend them gently near the end, not at the base.
- Use jumper wires with solid ends that fit the holes. Thin or frayed wire can pass a visual check and still fail to touch the strip.
- Keep wires short and flat against the board so you can see and trace them.
Testing the wiring without blink logic
Before you trust a new circuit with a program that has timing in it, check the circuit alone. Upload a sketch that does nothing except turn pin 8 on and leave it on.
const uint8_t LED_PIN = 8;
void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH); // Pin 8 stays at 5 V (or 3.3 V on 3.3 V boards).
}
void loop() {
// Nothing to do. The pin keeps its last output level.
}If the LED lights steadily, the whole path works: wiring, polarity, resistor and pin. A blink sketch then only adds timing, so any later fault points to the code. If it does not light, you have a wiring problem, not a sketch problem, and you have removed half the possible causes.
An output pin holds its level after digitalWrite() returns. That is why an empty loop() is enough here. The pin does not need to be rewritten on every pass.
You can run the opposite check by changing HIGH to LOW. The LED must then be off. This confirms that the LED's light really depends on pin 8 and not on a stray connection to a supply.
Measuring with a multimeter
If you own a multimeter, the check is more direct. With the sketch running and the LED lit, set the meter to DC volts. Measuring across the resistor should show roughly the supply voltage minus the LED's forward voltage. For a 5 V board and a red LED, that is about 3 V. Measuring across the LED itself should show about 2 V. These two numbers add up to the pin voltage, which confirms that the two parts are in series with the correct drops.
Common wiring faults
These are the mistakes that appear most often, with the symptom each one causes.
| Fault | What happens | How to spot it |
|---|---|---|
| LED reversed | LED stays dark, nothing is damaged at 5 V with a resistor | Long leg is on the GND side |
| Resistor and LED legs in different strips | Open circuit, LED dark | The resistor's second leg and the anode do not share a strip |
| Both LED legs in the same strip | LED is shorted out and stays dark, and the pin drives the resistor straight to GND | Anode and cathode in one five-hole group |
| Resistor missing | LED may light very brightly, then fail, and the pin is overloaded | Anode wired directly to the pin |
| GND rail not wired to the board | LED dark, no return path | No wire from the rail to a GND socket |
| Jumper in the wrong socket | Wrong pin is driven | Wire ends at a pin number other than 8 |
| Leg bridging the center channel | Part sits across both halves with nothing connecting | Legs in different halves of the same column |
The missing resistor deserves emphasis. A digital pin on a typical 5 V board is rated for roughly 20 mA in normal use, with an absolute maximum of about 40 mA. An LED with no resistor limits nothing, so the current is set by the pin's internal resistance and the LED's own behaviour. That can exceed the rating, and the damage often shows up later.
Why use a rail at all
You could run the cathode straight to a GND socket on the board with one jumper. For a single LED that works fine. Using a rail is a habit that pays off as soon as you add a second LED, a button or a sensor. Each of those needs a return to ground, and a rail gives you many connection points from a single wire to the board. Wiring the rail first also means a later part's ground connection is a short hop, not another long wire crossing the board.
Reading the circuit back
After building, trace the path with a finger or the tip of a pen, following the arrows in the diagram. Start at pin 8's jumper and say aloud which strip you enter, which part you cross, and which strip you reach. You should visit row 10, the resistor, row 14, the LED, row 15, the GND rail, and the GND socket. If you cannot name each strip on the way, there is a hole that does not match the plan. Fixing it now costs seconds. Finding it later while debugging a sketch costs much more.
The circuit is now ready. In the next chapter you will run a blink sketch on it, changing the pin number in one place if you moved the signal wire.
Exercise
You have built the circuit with the resistor in row 10 and row 14, and the LED anode in row 14, but the LED stays dark when the sketch drives pin 8 HIGH. A multimeter reads 0 V across the LED and about 5 V between row 10 and the GND rail. Where is the most likely fault, and why?
Show answer
The resistor's second leg and the LED anode are probably not in the same strip, or the cathode is not connected back to GND. The 5 V at row 10 shows that the pin and the jumper to row 10 work. The 0 V across the LED shows that no current is flowing through it, which means the path is open between the resistor and the LED, or between the LED and GND. Check that row 14 holds both the resistor leg and the anode, that the LED cathode strip is wired to the GND rail, and that the GND rail is wired to a board GND socket. A reversed LED would also give about 0 V across it only if no current flowed, so check its orientation too.
Exercise
A friend places the LED with both legs in row 15 and wires row 15 to the GND rail. The resistor connects pin 8 to row 14. Describe what is wrong and what the pin experiences.
Show answer
Both LED legs share one strip, so the LED is bypassed, and the current has no path through it. Row 14 and row 15 are different strips, so as drawn the resistor output reaches nothing, and the circuit is open with no current. If instead the anode were also in row 15, the resistor would connect pin 8 to GND through a short, and the pin would drive current limited only by the resistor. At 5 V and 220 Ω that is about 23 mA, which exceeds the 20 mA recommended per pin. Either way the LED never lights. Move the anode to the strip that holds the resistor's second leg, and keep the cathode in a different strip.