EM11 · Sem 6 · Embedded systems
LCD stopwatch with millis()
Aim: Show elapsed time on an LCD using millis().
🧪 Live simulation🧊 Real-time 3D bench⚠ Simulated values, not physical measurements
🔬 Virtual lab
Starting the lab…
📘 Theory
millis() returns time since start. Dividing into minutes, seconds and tenths and formatting with snprintf gives a stopwatch without blocking.
s = millis()/1000, tenths = (millis()/100) % 10
🧰 Apparatus (virtual)
- Dev board
- 16×2 LCD
📝 Procedure
🎤 Viva questions
Why not use delay() to keep time
Code between delays adds error; millis() is the true elapsed time.
What happens when millis() overflows
It wraps after about 49 days; subtract timestamps to stay correct.
🛡️ Safety
Virtual board. On real hardware, check supply voltages and pin current limits, and power motors and servos from a separate supply.