In my project on Arduino, I want to implement turning on the whole circuit by long press of a button.

But at the same time, I want the Arduino to be turned off in standby or sleep mode, but I don't know how to wake it up then.

Can you please advise me how this can be realized?

  • 1
    Your project has one button. You want a (*long) press of the button to wake the Arduino. After some time you want the Arduino to sleep (maybe to save battery power). You want the Arduino to wake again when there is a (*long) press of the button and all that in a continuous cycle. Is that correct or do you also want the Arduino to wake on other triggers as well ? (*Technically, the Arduino would wake on a short button press but immediately resume sleeping if the button press was too short)
    – 6v6gt
    Sep 16 at 11:11
  • @6v6gt Yes, it's just as you described. Ideally, I'd like it like this: - 3 seconds press (on) - Short press during operation (sleep mode) - Long press during operation (3 sec.) shutdown
    – EndyVelvet
    Sep 16 at 11:20
  • 1
    Which Arduino are you using ? Not all Arduinos, especially not development boards, bring significant power savings in sleep mode. You'd have to tolerate the Arduino entering "wake" mode as soon as the power supply is connected. There will only be wake and sleep states using software alone. A full shutdown is also possible but would involve additional hardware to unlatch the Arduino from the power supply. Do you require a full shutdown?
    – 6v6gt
    Sep 16 at 11:53
  • 1
    3 seconds press (on) - Short press during operation (sleep mode) - Long press during operation (3 sec.) shutdown ... please add that to the question ... it does not belong in a comment
    – jsotola
    Sep 16 at 17:54
  • 1
    you could use an ultra low power microcontroller to detect the keypress and control power to the arduino ... something like st.com/resource/en/datasheet/stm8l001j3.pdf
    – jsotola
    Sep 16 at 18:11

1 Answer 1


You can use a circuit like this to get close to what you want to achieve.

latching circuit

Found on: https://forum.arduino.cc/t/switch-microcontroller-on-and-off-with-a-button-and-mofset/1047044

It is a latching circuit with the special property that you can use the same button to power up the Arduino and later when the Arduino is running, test the button in code.

It works like this. If the Arduino is powered off, pressing the button powers up the Arduino. Your program will immediately (or after a specific chosen interval) switch on D6. This sustains the latch.

Now in your code, you can detect the button press and do what you like with it. Maybe power the device off by setting D6 to LOW if the button has been pressed for X ms.

If you want the device simply to enter sleep mode on a button press, then you can do that also. However, it gets a bit more complicated because the button then has to be used to wake the device. That means setting a pin change interrupt on pin A0 and then testing A0 on wake up to determine the length of the button press. If it is too short, then you can force the Arduino to resume sleep.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.