Press On / Hold Off BTN

Hello guys, i’m trying to implement a safety On-Off switch both for microcontrollers or microcomputers like RPI or lattePanda. The image below show the circuit that i want to implement. My first problem is that idk really what does mean Auto-Off or Auto-On in the schematic, i thought it was a relay maybe…if i ignore it and i connect a wire between 0.1uF cap and the point “Auto Off” its work but the first state is On, then when i press the btn 2~4Sec the device will turn off, so if i press again it turn On.

If i plug a power supply it will automatically start On, and i want the first state to be Off.

Any suggestion?

latching-push-button-power-toggle-switch-circuit-for-microcontroller.png

OK, let's look at your circuit.
latching-push-button-power-toggle-switch-circuit-for-microcontroller.png
"Auto-Off or Auto-On" means you select whether it will be off or on when you first connect it to power.

I tried it by using a spdt switch, still not working :confused:

If there are any relays the part number
should be shown. Where did you get this schematic ?
"I/O pin" is a bit vague . Presumably it means output.
For starters, each mosfet should have a unique designator. I don't care
how many there are in the package, whether it is "dual" or a gazillion,
they should be labeled Q1, Q2 etc. That's Electronics 101.
They are clearly visible in the datasheet. Why aren't they in the schematic ?
Moreover ALL the resistors should have UNIQUE designators (R1, R2, R3 etc). That's Electronics 101.
The switches should have SW1, SW2, designators, regardless of the function names. That's Electronics 101.

My first suggestion would be eliminate the microcontroller and replace the "I/O PIN" with an SPDT
switch that allows you to connect the "I/O PIN" node to either +5V or GND.
Then put a DMM on the output and record the results while operating the switches.
Make a table that contains the following:
CONDITIONS I/O PIN INITIAL OUTPUT VOLTAGE FINAL OUTPUT VOLTAGE


SW1 OFF SW2 OFF LOW ? ?
SW1 ON SW2 OFF LOW ? ?
SW1 OFF SW2 ON LOW ? ?
SW1 ON SW2 ON LOW ? ?
SW1 OFF SW2 OFF HIGH ? ?
SW1 ON SW2 OFF HIGH ? ?
SW1 OFF SW2 ON HIGH ? ?
SW1 ON SW2 ON HIGH ? ?

When you have completed that presumably you'll know how to write your code.

Omicron91:
Hello guys, i’m trying to implement a safety On-Off switch

Maybe rewind to what you actually want.

A latching circuit and a safety circuit seem opposite to me.

How do you want this to actually work?

I have had problems in the past by connecting a power supply directly to a microcontroller or microcomputers, even if it passes through a simple spdt sw and a voltage regualtor. Actually i'm working in a telemetry device wich include a raspberry with a quectel20uc for GSM/3.5g communication, the are delicated device electronically, and this must be connected 24x7, if the device is not properly turned off you can corrupt the kernel, or you could damage certain parts and i want to avoid that.

Anyway, i'm not an expert so...all recomendations are welcome

The instructions were to REMOVE the microcntroller and complete the table.
You asked us for help. If you're not going to follow simple instructions then why are you posting on the forum ?