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.
- Carte
- Nano 33 BLE · Arduino
- Difficulté
- Facile
- Thème
- GPIO & Digital Outputs
- Accès
- Gratuit
La tâche
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.Serialis 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.
- D2
- 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().
- State, by priority. The cradle is in exactly one state, decided in this order:
FAULTlow: FAULT (whatever the other lines say);- otherwise
PGhigh: NO-INPUT; - otherwise
DONElow: FULL; - otherwise: CHARGING.
- 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.
- Report. Print
STATE <name>(STATE CHARGING,STATE FULL,STATE FAULT,STATE NO-INPUT) once afterREADYand 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
- The sketch builds.
- Each state shows its own LED pattern.
- A fault overrides every other state.
- One
STATEline per change, and the LED always matches it.
Ce que vous obtenez
- Votre firmware est compilé et exécuté sur une carte émulée, puis vérifié par des tests matériels.
- Une explication écrite de la solution.
- Aucune carte de développement ni toolchain locale requise.
Débutant en embarqué ? Commencez par la feuille de route : Apprendre les systèmes embarqués (en anglais)