Result. The SEAF helmet light works on the real bench. A 9 V battery powers an ESP32 and an RGB LED (all three colours on, so it looks white). A 2N2222A transistor switches the LED, and the 17-key IR remote controls it: OK turns it on and off, 1 steady, 2 pulse, 3 strobe, 4 SOS, 5 failing lamp. It runs on the ESP32 that used to run the LED Blink Sequence.
The build. Everything sits in the bottom half of the breadboard (rows f–j) on the bottom rails: outer = +, inner = −.
| Part | Goes to |
|---|---|
| 9 V battery + / − | bottom + rail / − rail |
| ESP32 VIN / GND | + rail / − rail |
| RGB LED red | + rail → 330 Ω → 100 Ω → red leg (≈15 mA) |
| RGB LED green, blue | + rail → 330 Ω each (≈16.5 mA each) |
| RGB LED common (long leg) | transistor collector |
| 2N2222A | E f10 (→ − rail), B f11, C f12 |
| 1 kΩ base resistor | GPIO 26 → base |
| IR receiver S / VCC / − | GPIO 27 / GPIO 25 (driven HIGH) / − rail |
My transistors are printed 2N2222A 331: plastic TO-92, legs E-B-C with the flat face toward me. The "331" is just a date or batch code. My resistor kit has no 470 Ω, so red uses 330 Ω + 100 Ω in series.
The faults, in the order I found them
1. The IR signal wire wasn't on GPIO 27. The light did nothing and no codes showed up. Once the receiver's S pin was on 27, every button showed its code in the serial log, and they matched what the sketch expected.
2. The lamp stayed on. The board said GPIO 26 was at 0 V (lamp off), but the LED stayed lit. Flipping the transistor didn't fix it (it was right the first time: E-B-C). The test that cracked it: I pulled the transistor out, and the LED went dark. So the LED wiring was fine and the current was going through the transistor, which meant its base was getting current from somewhere other than the pin.
3. The real cause: my GPIO 26 jumper wasn't in the 1 kΩ resistor's row. The pin had no connection to the base, so switching it "off" did nothing. With the wire in the same row as the resistor's leg, the lamp follows the remote properly.
4. One OK press sometimes toggles twice. The remote can send a burst of codes for one press. The sketch now ignores OK for 600 ms after a toggle, which mostly fixes it.
What I learned
- A leg and a jumper only connect if they're in the same numbered row, on the same half of the board. One hole off isn't connected, however close it looks.
- Pulling a part out is a quick test. If the LED went dark without the transistor, the problem was what fed the transistor, not the LED wiring.
- A transistor's base needs a definite low to turn off. A base that isn't connected to anything doesn't reliably mean off.
- Read the transistor's print before trusting a pinout: 2N2222A (TO-92) is E-B-C, but a P2N2222A is C-B-E.
Comments (0)