# leds-buzzer — the robot's heartbeat (minirobo EP5)

A blinking LED and a beeping piezo buzzer, timed together like a pulse. The
first two parts on the channel that give a robot feedback instead of just
taking commands.

## Wiring

| Part | Connects to |
|------|-------------|
| LED anode (long leg) | 220Ω resistor → GPIO 20 |
| LED cathode (short leg / flat side) | GND |
| Buzzer + | GPIO 21 |
| Buzzer − | GND |

No resistor on the buzzer — a small piezo disc pulls only a few mA, well
within what the pin can drive directly.

## The resistor math

`(supply V − LED forward V) ÷ desired current`

For a red LED on the ESP32's 3.3V rail at about 10 mA: (3.3 − 2.0) ÷ 0.01 =
130Ω minimum. **220Ω** clears that with margin and is a safe default for
almost any small LED. Bigger resistor = dimmer, never dangerous. Skipping
the resistor entirely kills the LED in well under a second.

## Active vs. passive buzzer

This sketch uses `tone()`, which only works on a **passive** piezo buzzer —
one with no chip inside, just a disc that vibrates at whatever frequency you
feed it. An **active** buzzer has its own oscillator and only knows one
note; `tone()` does nothing on it, and you'd drive it with a plain
`digitalWrite(pin, HIGH)` instead. If your buzzer stays silent or plays one
flat tone regardless of frequency, you likely have an active one.

## Gotchas

- **LED backwards** just stays dark — safe to flip and retry, no damage.
- **One resistor per LED.** Sharing a resistor across two LEDs makes them
  split current unevenly; one runs hot, the other stays dim.
- **Piezo buzzers are loud up close.** Don't bench-test one next to your ear.

## The challenge

Give your robot a heartbeat: blink the LED and beep the buzzer together,
once a second. Post a clip in the comments on YouTube.

More: https://minirobo.io/episodes/leds-buzzer.html
