I'm using seep sleep mode with UNO with a simple sketch that turning on an LED and then goes to sleep. as far as the ATmega328p datasheet in sleep mode part showing the wake up sources and deactivated clock sources in deep sleep mode and the I/O clock becomes deactivate so we expect when the board goes to sleep the LED should become off because of no clock. but it doesn't happen and LED keeps ON in sleep mode. what is the problem?7 and how can we even find out that the board is on sleep mode or not?
-
Why do you think, that the output will be turned off, when going to sleep? As of my understanding, the value of the pin cannot change in sleep, since the latch does not have a clock signal. But that doesn't mean, that the output is turned off.– chrislMar 24, 2020 at 13:29
-
use the LED to indicate sleep mode ... turn off led upon wakup– jsotolaMar 24, 2020 at 21:08
2 Answers
The IO doesn't require the clock to keep its current state. It only requires it to change state.
There is no real external signal provided by the chip to indicate if its in sleep mode or not. However you could monitor the current consumption of the chip and when it drops below a certain threshold you can assume that it is in sleep mode.
You could easily set the LED output LOW just before you call going_to_sleep(), and set it HIGH when going_to_sleep() returns. There would be two short periods where the LED signal would indicate sleeping but the processor is running:
- between the LED going LOW and the processor actually entering sleep; and
- between the processor waking and the LED going HIGH.
But at these times the processor could not respond to your external system anyway.