Charger Status Indicator

On an Arduino Nano 33 BLE, turn three active-low charger status lines into one LED: off, steady, slow blink or fast blink, chosen by priority, with a fault overriding everything and one STATE line per change.

Placa
Nano 33 BLE · Arduino
Dificultad
Fácil
Tema
GPIO & Digital Outputs
Acceso
Gratis

La tarea

Charger Status Indicator

A warehouse scanner sits in a charging cradle overnight. The cradle's charger chip reports three status lines, and one LED on the front must tell the night shift what is going on, at a glance and from across the room.

Hardware

  • Arduino Nano 33 BLE (nRF52840, 3.3 V logic). Serial console on Serial1 (D0/D1), 115200 baud. Serial is USB and is not seen by the tests.
  • The charger chip's status outputs are open-drain and active low. Use the internal pull-ups.
    • D2 PG: LOW = input power is present.
    • D3 DONE: LOW = the battery is full.
    • D5 FAULT: LOW = battery temperature fault.
  • D4: status LED with a series resistor to GND, HIGH = on.
  • The status lines are clean logic signals (no bounce).

Requirements

Write the sketch in sketch/sketch.ino (setup() and loop()). In setup() open Serial1 at 115200 baud, set up the pins, then print READY and the first state line. Never block with delay().

  1. State, by priority. The cradle is in exactly one state, decided in this order:
    1. FAULT low: FAULT (whatever the other lines say);
    2. otherwise PG high: NO-INPUT;
    3. otherwise DONE low: FULL;
    4. otherwise: CHARGING.
  2. LED pattern. NO-INPUT: off. CHARGING: steadily on. FULL: slow blink, 500 ms on, 500 ms off. FAULT: fast blink, 125 ms on, 125 ms off. A blink starts with on at the moment its state begins.
  3. Report. Print STATE <name> (STATE CHARGING, STATE FULL, STATE FAULT, STATE NO-INPUT) once after READY and then once each time the state changes, within 20 ms of the input change. The LED follows the new state from the same moment.

Example console output:

READY
STATE NO-INPUT
STATE CHARGING
STATE FULL
STATE FAULT
STATE FULL

Wiring

Build the circuit in the Wiring tab: the charger's PG, DONE and FAULT outputs to D2, D3 and D5 (its GND to GND), and the status LED on D4 through a series resistor of 220 to 1000 ohm (resistor on the pin side, LED cathode to GND). A wrong or incomplete circuit blocks Run.

Success criteria

  1. The sketch builds.
  2. Each state shows its own LED pattern.
  3. A fault overrides every other state.
  4. One STATE line per change, and the LED always matches it.

Qué incluye

  • Tu firmware se compila y ejecuta en una placa emulada y se comprueba con pruebas a nivel de hardware.
  • Una explicación escrita de la solución.
  • No necesitas placa de desarrollo ni toolchain local.

¿Nuevo en embebidos? Empieza por la hoja de ruta: Cómo aprender sistemas embebidos (en inglés)