Resistors & Components
Passive components used in cockpit builds — reading colour codes, calculating LED resistors, and choosing capacitors.
Resistors are the most common passive component in any cockpit build. They protect LEDs from overcurrent, form voltage dividers for analog sensors, and provide pull-up or pull-down biasing for digital inputs.
Reading 4-Band Colour Codes
| Colour | Digit | Multiplier | Tolerance |
|---|---|---|---|
| Black | 0 | ×1 | — |
| Brown | 1 | ×10 | ±1% |
| Red | 2 | ×100 | ±2% |
| Orange | 3 | ×1 k | — |
| Yellow | 4 | ×10 k | — |
| Green | 5 | ×100 k | ±0.5% |
| Blue | 6 | ×1 M | ±0.25% |
| Violet | 7 | ×10 M | ±0.1% |
| Grey | 8 | — | ±0.05% |
| White | 9 | — | — |
| Gold | — | ×0.1 | ±5% |
| Silver | — | ×0.01 | ±10% |
Common values for cockpit builds
| Value | Use case |
|---|---|
| 68 Ω – 100 Ω | LED current limiting from 3.3 V supply (standard LEDs ~20 mA) |
| 220 Ω – 330 Ω | LED current limiting from 5 V supply; indicator LEDs at reduced brightness |
| 1 kΩ – 10 kΩ | Base resistor for NPN transistors driving LEDs or relays |
| 10 kΩ | External pull-up or pull-down for digital inputs |
| 4.7 kΩ | I²C pull-up (SDA / SCL lines) |
Every LED needs a series resistor to limit current. Without one the LED will draw as much current as the supply can provide and burn out instantly.
Formula: R = (Vsupply − Vforward) ÷ Iforward
| LED colour | Typical Vf | Typical If | R from 3.3 V | R from 5 V |
|---|---|---|---|---|
| Red | 1.8–2.2 V | 20 mA | 56–75 Ω → 68 Ω | 140–160 Ω → 150 Ω |
| Yellow / Orange | 2.0–2.2 V | 20 mA | 55–65 Ω → 68 Ω | 140–150 Ω → 150 Ω |
| Green | 2.0–3.0 V | 20 mA | 15–65 Ω → 33–68 Ω | 100–150 Ω → 100 Ω |
| Blue / White | 3.0–3.4 V | 20 mA | 0–15 Ω → use 33 Ω min | 80–100 Ω → 100 Ω |
A floating GPIO pin (nothing connected) will give random readings. A resistor anchors the pin to a known voltage when the switch is open.
| Configuration | Resistor connects | Idle (switch open) | Active (switch closed) |
|---|---|---|---|
| Pull-up | GPIO → 3.3 V | HIGH | LOW (switch to GND) |
| Pull-down | GPIO → GND | LOW | HIGH (switch to 3.3 V) |
The ESP32 has built-in ~45 kΩ pull-up resistors on every GPIO — enable with pinMode(pin, INPUT_PULLUP). External 10 kΩ pull-ups provide a stronger reference and are preferred when the wire run is long (>30 cm) or the signal line is near power wiring that could induce noise.
An ESP32 GPIO can source/sink a maximum of 40 mA (12 mA recommended). For higher loads — multiple LEDs, a buzzer, a relay coil — use an NPN transistor as a low-side switch. The GPIO drives the base through a resistor; the transistor switches the load.
| Transistor | IC max | Use case |
|---|---|---|
| 2N2222 | 600 mA | Single LED strings, small buzzers |
| BC547 / BC337 | 100–800 mA | Annunciator LED banks, relay coils |
| TIP120 (Darlington) | 5 A | Motor control, large LED arrays, solenoids |
Base resistor calculation: RB = (VGPIO − VBE) ÷ IB, where IB = IC ÷ hFE. A 1 kΩ base resistor is a safe starting point for most NPN transistors at GPIO logic levels.
Capacitors appear in two roles in cockpit builds: decoupling (suppressing voltage spikes near ICs) and filtering (smoothing power rails). They are not optional near motor drivers and stepper controllers.
| Value | Type | Use case |
|---|---|---|
| 100 nF (0.1 µF) | Ceramic | Decoupling cap across VCC/GND on every IC; place as close as possible |
| 10 µF | Electrolytic or ceramic | Bulk decoupling near ESP32 VIN; helps with Wi-Fi transmit spikes |
| 100 µF | Electrolytic | Required across VMOT/GND on A4988 / DRV8825 stepper drivers |
| 1 000 µF + | Electrolytic | Main power rail filter when multiple servos share a supply |
Two diode types appear regularly in cockpit wiring:
| Diode | Purpose | Where to use |
|---|---|---|
| 1N4007 (rectifier) | Flyback / freewheeling — absorbs voltage spike when inductive load switches off | Across relay coils, motor driver outputs, solenoid valves |
| 1N4148 (signal) | Reverse-polarity protection; signal isolation in diode matrix keyboards | Button matrices, input protection on sensitive GPIO lines |
| Schottky (e.g. 1N5819) | Low forward voltage drop (0.3 V) — power path selection, OR-ing supplies | Dual-power schemes (USB + bench supply), OR-ing two ESP32 power inputs |