Power Nano Through Digital Pins?

Is there a reason why my Nano is begin powered up through digital pins. I have toggle switches that I want to read either HIGH or LOW . I'm using an external 5v power supply to the switches. I don't have a USB plugged into it or anything going to the VIN pin. When I flip a switch the nano powers up.


My_Sketch.ino (1.9 KB)


const int relay1 = 2;
const int switch1 = 3;
int redled = 4;
int greenled = 5;
const int relay2 = 8;
const int switch2 = 9;
const int button = 10;
const int switch3 = 11;

#define Xjoystick A0
#define Yjoystick A1
signed int rotation, elevation;

const int deadzone = 100;  // Adjust this value as needed

int sw1val;
int sw2val;
int butval;
int sw3val;
int homePos = 0;
int speed1 = 800;
int speed2 = 3200;

void setup() {
  pinMode(redled, OUTPUT);
  pinMode(greenled, OUTPUT);
  pinMode(relay1, OUTPUT);
  pinMode(switch1, INPUT);
  pinMode(relay2, OUTPUT);
  pinMode(switch2, INPUT);
  pinMode(button, INPUT);
  pinMode(switch3, INPUT);
 
  digitalWrite(relay1, HIGH);
   
 
  Serial.begin(9600);
}

void loop() {
  int Xaxis = analogRead(Xjoystick);
  int Yaxis = analogRead(Yjoystick);
  sw1val = digitalRead(switch1);
  sw2val = digitalRead (switch2);
  butval = digitalRead(button);
  sw3val = digitalRead(switch3);

  rotation = map(Xaxis, 0, 1023, -100, 100);
  elevation = map(Yaxis, 0, 1023, -100, 100);

  if (abs(rotation) < deadzone) {      // Apply deadzone: if the value is within the deadzone, set it to 0
    rotation = 0;
  }
  if (abs(elevation) < deadzone) {
    elevation = 0;
  }

  Serial.print("Rot: ");
  Serial.print(rotation);
  Serial.print("  Elev: ");
  Serial.print(elevation);
  Serial.print("  Switch1: ");
  Serial.print(sw1val);
  Serial.print("  Switch2: ");
  Serial.print(sw2val);
  Serial.print("  Button: ");
  Serial.print(butval);
  Serial.print("  Switch3: ");
  Serial.println(sw3val);
  delay(100);
  
    if (sw1val == 1) {
    digitalWrite(relay2, HIGH);
  }
  if (sw1val == 0) {
    digitalWrite(relay2, LOW);
  }
  if (sw2val == 1 && butval == 1 && sw3val == 0) {
   digitalWrite(redled, HIGH);
    delay(100);
    digitalWrite(redled, LOW);

  }

  if (sw2val == 1 && butval == 1 && sw3val == 1) {
   digitalWrite(greenled, HIGH);
    delay(100);
    digitalWrite(greenled, LOW);

  }

}

It's called "Ghost powering" and it 's not good.
Why have separate power to the swiches at all?

1 Like

Yes. As your setup uses positive switching switches you will power up your board.
BUT! Each pin can handle 1mA max. You may already have damaged some I/O pins.
Using switches switching to ground with the internal pull up resistors, this will not happen.
Your circuit is quite small, it can easily be supplied from the 5V pin when powered by USB.
Powering with 7V to the barrel jack is also possible.
With 12V to the barrel jack you will approach a limit for heat dissipation in the 5V regulator.

1 Like

The project is a pan/tilt camera that is approx 250' from my house using cat5. I have a control box in the house with a joystick. The box is powered with 12v and then steps down to 5v to go to the switches When I power on the box it sends 12V to the Nano and to a 12V light (not connected to the Nano). In the code the first thing that happens is a relay is turned on which has 110V to power up a security camera and a 24V 20amp power supply that supplies power for a nema 23 stepper motor driver and a Cytron MDDS30 motor driver, which powers 2 electric scooter motors (Pan/Tilt) with gear reductions. The site where I made the schematic don't have the components to draw everything.

Using pen and paper ought to be good enough. Your reply does not answer the question.

1 Like

It is also called parasitic powering, and will damage the Arduino pin / board.

This happens because you are not powering the Arduino from your power supply. The simple solution is to run +5V and ground from your power supply to the 5V pin and one of the ground connections on the Arduino.

1 Like

That's the correct name.

So I shouldn't use the VIN pin?

The input to the 12V to 5V buck should be connected AFTER the keyswitch not directly to the 12V supply. That way the keys won't be powered if the Arduino is not powered, so no back-powering will occur.

Correct, because the Vin pin passes through a regulator that requires about 7V "head room" to regulate down to 5V.

You're correct. That's the way I wired it. I don't know why I put it before the keyswitch in the diagram... I just noticed that...lol

So that is the only thing you need to change. Everything else can stay the same.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.