Seatbelt Reminder Lamp

On an Arduino Nano 33 BLE, flash a belt warning lamp when the ignition is on and the belt stays unlatched for two seconds, and start the grace period over every time the situation begins again.

Placa
Nano 33 BLE · Arduino
Dificultad
Fácil
Tema
Timing & Program Flow
Acceso
Gratis

La tarea

Seatbelt Reminder Lamp

A delivery-van maker is adding a belt reminder to its instrument cluster. When the ignition is on and the driver's belt is not latched, the belt lamp must start flashing after a short grace period, and go dark the moment the buckle clicks in. Times are shortened for the bench.

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.
  • D2: ignition switch, closes to GND while the ignition is on. Use the internal pull-up: LOW = ignition on.
  • D3: buckle switch, closes to GND while the belt is latched: LOW = latched.
  • D4: belt warning lamp (LED with a series resistor to GND), HIGH = lit.
  • Both switches reach the board through the cluster's input filter, so they do not bounce.

Write the sketch in sketch/sketch.ino. In setup() open Serial1 at 115200 baud, set up the pins with the lamp off, then print READY. Never block with delay(): both switches are read all the time.

Requirements

  1. When to remind. The reminder applies only while the ignition is on and the belt is not latched. In every other situation the lamp is off.
  2. Grace period, then flashing. Once that situation has lasted 2000 ms without a break, print REMIND ON and flash the lamp 500 ms on, 500 ms off, starting with on, for as long as the situation lasts.
  3. Cancel and start over. When the belt is latched or the ignition is switched off, the lamp is off within 20 ms; if it was flashing (and only then), print REMIND OFF. Each time the reminder situation begins again, the 2000 ms grace period starts again from zero.

Example console output:

READY
REMIND ON
REMIND OFF

Wiring

Build the circuit in the Wiring tab: the ignition switch between D2 and GND, the buckle switch between D3 and GND, and the warning lamp LED on D4 with a series resistor of 220 to 1000 ohm on the pin side and the LED cathode to GND. A wrong or incomplete circuit blocks Run.

Success criteria

  1. The sketch builds.
  2. The lamp stays dark while the ignition is off or the belt is latched.
  3. With the ignition on and the belt open, REMIND ON comes after 2 s and the lamp flashes at 1 Hz.
  4. Latching the belt or switching off stops the lamp at once, and the next reminder waits the full 2 s again.

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)