Go Down

Topic: Auto Power Off - not working :( (Read 3 times) previous topic - next topic

ArJack

May 10, 2012, 11:54 am Last Edit: May 15, 2012, 11:35 am by ArJack Reason: 1
Hi all,
I've tried a couple of ways to make Arduino cut power through a digital pin.
The first is based on a PNP (push button to start power, then digital pin set LOW to maintain it, set HIGH to cut).


The second is based on an NPN (push button to start power, then digital pin set HIGH to maintain it, set LOW to cut).


In both cases, if I don't connect the digital pin, pushing on the button, power goes on. But if I connect the pin, power goes on immediately.
Is it something related to the fact that, by default, pins are INPUT? Please help, do you have any suggetion?
Thanks!

PaulS

You need more than an Arduino to do anything like this. You need some code on the Arduino. If that code isn't working properly, and you want help to fix it, you need to do something about the fact that we can't see your code.

ArJack

Thanks PaulS, you're right, Here's my code for the first case:

Code: [Select]
/*
  Blink
  with auto-power-off (PNP)
*/

void setup() {               
  pinMode(2, OUTPUT);      // digital pin as output
  digitalWrite(2, LOW);   // keep power on
 
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
}

void loop() {
  for (int i=0;i<10;i++)   // blink LED ten times
     {
  digitalWrite(13, HIGH);   // set the LED on
      delay(3000);
      digitalWrite(13, LOW);    // set the LED off
      delay(1000);
}
 
  digitalWrite(2, HIGH);  // force power off
}


and here's the code for the second case:
Code: [Select]
/*
  Blink
  with auto-power-off (NPN)
*/

void setup() {               
  pinMode(2, OUTPUT);      // digital pin as output
  digitalWrite(2, HIGH);   // keep power on
 
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
}

void loop() {
  for (int i=0;i<10;i++)   // blink LED ten times
     {
  digitalWrite(13, HIGH);   // set the LED on
      delay(3000);
      digitalWrite(13, LOW);    // set the LED off
      delay(1000);
}
 
  digitalWrite(2, LOW);  // force power off
}

PaulS

I think we need to see a wiring diagram, now. What are you trying to cut power to?

In both of the sketches, the blinking LED does nothing useful. After 40 seconds, one sketch will unconditionally turn the pin off. The other will unconditionally turn the pin on.

Neither knows anything about the button you are pushing.

michael_x


Neither knows anything about the button you are pushing.

The first entry shows two variants even.
Quote
In both cases, if I don't connect the digital pin, pushing on the button, power goes on. But if I connect the pin, power goes on immediately.
Is it something related to the fact that, by default, pins are INPUT? Please help, do you have any suggetion?

If pushing the button has any effect, your wiring must be different.
You cannot use an Arduino input pin, to switch the Arduino ON (probably I misunderstood your post)
You are feeding a high base current into your transistors. Are they still alive?

Go Up