Answer the question
In order to leave comments, you need to log in
How to turn off the arduino, and then turn it on with the button?
How to turn off the arduino, and then turn it on with the button? For example, I made a robot, it works, it works, then how to turn it off completely? And then turn it on by pressing a button?
Answer the question
In order to leave comments, you need to log in
When the button is pressed, the microprocessor goes to sleep.
From sleep, it can only be awakened by an interruption by pressing the same button.
You need to connect the button to one of the hardware interrupt pins (usually 2 or 3) and then configure the interrupt handler.
https://playground.arduino.cc/Learning/ArduinoSlee...
Sleep, interruptions - is it about this in the question? There's "how to completely turn it off"!
Roma Kotolup , take a toggle switch or, if you prefer, a button with a fixation and power the arduino through it. Everything, the task is solved.
Sleep has already been written about. If you need a complete shutdown - put a transistor in the power gap, start its control on one of the pins of the arduino, and parallel to this pin - a button without fixing.
We press the button, the transistor opens, the controller first of all picks up power management, after releasing the button, the transistor remains open. When you need to programmatically turn off, just turn off the pin.
If you need to monitor button presses in the on state, you need to untie it from the transistor through a diode and start the signal directly from the button to another pin.
I use such a solution in my boards, for high and low voltage.
After the button closes the contacts, power is supplied to the entire system and the MK must send a signal to POWER_RETENTION, so while the signal is energized,
PUSH_BUTTON always goes to the MK input, after turning it on it becomes with a regular button, you can program different functions for short clicks, multi-clicks, and then make it so that when you hold it for a long time, the device prepares to turn off the power and resets the POWER_RETENTION signal, thereby turning itself off
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question