I am trying to build a circuit that will allow my arduino board to be turned on by a button (switch). Much like a power button on PC. Here is my schematic.
In real life I used a phone charger instead of the battery.
And here is arduino code.
void setup() {
pinMode(11, OUTPUT);
pinMode(11,HIGH);
}
void loop() {
// put your main code here, to run repeatedly
}
The setup should work like this.
- The user press the button
- Arduino GND pin is connected to phone charger GND
- Arduino starts
- Arduino pin 11 goes high
- The pin activates the 2n2222 transistor
- The transistor connects other arduino GND pin to ground
- User releases the button
- Arduino stays on
The problem is, when I plug in the charger, arduino turns on without user pressing the button! I found the transistor to be guilty because if I disconnect the transistor collector from arduino gnd pin, arduino shuts down. Tried changing the transistor and no luck. Same thing happens if I put pin 11 to LOW in the code. I have no idea what's happening here and how is this possible. I'm relatively new to the electronics. Are there any possible workarounds that don't involve complicated circuitry? Also bare in my that I have only 2N2222 NPN transistors, so solutions involving FET, MOSFET, PNP and other transistors won't help me. Thank you in advance!!