Switch Microcontroller with a button on and off

HI all,

probably a easy question, but couldn´t find the right answer. I am looking how to switch on and later off a microcontroller (anything small) by just pressing a button.
What I want to do: I have a little LED project. When Someone is pressing a button, an animation will start (I can do this with arduino myself). When Pressing the button,again the next animation should start. When long pressing, the system should switch off completely to safe energy. Basically like a bike backlight with different strobe effects.

Happy for any hint and help

Regards

Kresi

Here's a circuit I've used. The push button turns on the power, but it also serves as an input device to the processor. See if you can understand how the power stays on, and how the processor can turn it off after a long press.

1 Like

Interesting circuit ShermanP, thanks for sharing!

I think I understand your circuit. I am not going to post the workings here, so Kresi can still have a learning experience. But it does require some lines of code for the power to stay on right? :slight_smile:

Yes it does - very early in the code. It also requires code to deal with subsequent short and long presses, and to turn off the power.

Hi,
thanks @ShermanP for your circuit. I will have for sure have some learnings here. Could you please explain what the part labeled on the top with S/D is? Is this a kind of rectifier?
Sorry for asking. I learned myself to read most of these schematics but still learning ;-).

@Mardec: if you have made something working, it would be appreciated to learn from you too :slight_smile:

Regards

Kresi

It's a P-channel MOSFET, used as a switch. There are many videos on Youtube about MOSFETs.

Thanks ShermanP. Will take a look at it