Rock YouTube channel with real views, likes and subscribers
Get Free YouTube Subscribers, Views and Likes

Arduino self power off - mosfet + 220k + button

Follow
chlordk

Connect a mosfet "source" to external power ground (blue) and "drain" to Arduino "gnd" (white).
Connect a push button to "drain" and "source".
Connect a resistor 220k (or 100k) to "gate" and "source".
Connect "gate" (orange) to pin 7 on Arduino.
Connect external power +6volt to Arduino plus.

Load up the program and push the button: Arduino turns on for 5 seconds and turns it self off.

Inspired by
http://www.zolalab.com.br/eletronica_...

=== code ===

#define EXT_POWER 7

void setup() {
pinMode(EXT_POWER, OUTPUT);
digitalWrite(EXT_POWER, HIGH);
pinMode(LED_BUILTIN, OUTPUT);
}

int count = 10;

void loop() {
if (count) {
digitalWrite(LED_BUILTIN, count % 2 );
delay(1000);
} else {
digitalWrite(EXT_POWER, LOW);
while (1) {
digitalWrite(LED_BUILTIN, ++count % 2 );
delay(100);
}
}
}

posted by Amaletak2