So I have this circuit here. Ideally, it allows a momentary switch to connect the power circuit, and when released it would stay on.
Here's what I think this circuit does.
- The button is pressed
- Power flows and the micro controller begins running it program
- Software says to supply voltage on PB3
- Transistor turns on connects the circuit to ground
- The button is released, and the transistor stays connected.
Here's what it doesn't do yet:
- While power is on, hold the button for 1 second (how would I do this?)
- micro notices a long press on the button
- Software says to remove voltage from pin PB3
- Transistor disconnects and the circuit is disconnected
The only part of that I'm not getting is how the chip can detect the button state if both sides are connected to ground.
So two related questions: Will this work to latch power on? And how can the chip know the same button state so it can turn itself off?