Arduino Powers on With Power Applied to Input Pin

The same issue has occurred on a barebones freeduino, an Arduino Uno Rev 3, and now a Nano V3. The project is this, I have a license plate bracket that has 2 skulls on each side. I have wired it into my car's electrical system so that the eyes of the skulls will glow a specific color based on the scenario (lights on, brakes applied, car in reverse, etc). I have all of the inputs running through 7805 voltage regulators to bring the power down to 5V. However, when I turn on my headlights without applying power to the Arduino (it has an on/off switch for the main power), the Arduino will power on. I can tell this by the fact that LED's are on. While in this state, I have disconnected power from the DC Jack and the arduino stay's powered on. I have disconnected the LED harness (I have a quick disconnect) and it stays powered on. Once I remove the harness for the inputs, it powers down.

I have the PINs setup as input and output appropriately (as shown below)

// Setup pin functions
  pinMode(leftRed, OUTPUT);
  pinMode(leftGreen, OUTPUT);
  pinMode(leftBlue, OUTPUT);
  pinMode(rightRed, OUTPUT);
  pinMode(rightGreen, OUTPUT);
  pinMode(rightBlue, OUTPUT);
  pinMode(A5, INPUT); // Brake
  pinMode(A1, INPUT); // Reverse
  pinMode(A2, INPUT); // License
  pinMode(A3, INPUT); // Left Turn
  pinMode(A4, INPUT); // Right Turn

Obviously I have tried different boards and different inputs but I have not been able to stop this from happening. My sketch keeps being erased and I believe that this is the cause. I have done research but I'm either searching for the wrong words or missing something obvious. If anyone can help I would greatly appreciate it. Also, if anyone wants a diagram or the code, let me know and I will post it for you.
Jay

Applying more than VCC + 0.5 volts (which is 0.5 volts when the board is not powered) to a pin will damage the processor.

As you have discovered, when a processor is not powered, electricity applied to a pin can make its way through the processor and bring it partially to life.

I have done research but I'm either searching for the wrong words or missing something obvious.

This has been discussed several times on the forum. Unfortunately, I cannot think of any keywords to help your search.

I have all of the inputs running through 7805 voltage regulators to bring the power down to 5V.

This is quite creative, but it guarantees the inputs will have all the power you need to cook your arduino.

Have you considered a more conventional approach to conditioning the inputs like opto-isolation or even a resistor divider?

-br

darktide:
all of the inputs running through 7805 voltage regulators to bring the power down to 5V.

What you should be doing is using 5.1V Zener dioes, along with a circuit that only takes signals to the Arduino's input pins if there is power applied to the arduino (a simple NPN transistor can take care of that) . Not only 7805 are way too expensive for this simple task, but it adds complexity to the circuit and waste power.

Search for CMOS protection diode. So far in my experience, unless you pass so much current thru them that they burn out, it really won't hurt anything. The device simply powers up. They can be intentionally formed into the circuitry, or they can be an artifact of the CMOS manufacturing process.

Alex,
I ran into the 7805 because it was the only one that explicitly said that it would convert 12v to 5v. At this point price isn't worrying me since I got them relatively inexpensive off ebay. Would a zener diode drop 12v down to 5v? I will continue to do my research to work out the NPN transistors. Once I'm able to get my hands on these components I will put it all together and let you know how it turns out!

I'm impressed at how little I really know of electrical. Thank you all for your help and advice, it is helping me learn and that's why I came here so thank you.

Looking at the NPN configuration, I'm unsure which leg to connect to the arduino's input pin, ground, and input voltage. I'd like to give my best guess and then be corrected if necessary.

Base - Wire from arduino to let the transistor know that it is alive
Collector - Input Voltage wire
Emitter - Wire to Arduino's input pin

From what I can tell, using the 7805's is giving the proper voltage but I'm worried about passing along enough voltage to fry my arduino (as Billroy warned). Any advice on how to wire in the zener diodes would be greatly appreciated.
Jay

About half-way down this page you can see how to switch a load with a digital pin and an NPN:

Load is "above" the NPN, between V+ and collector
Arduino digital i/o pin is to base, thru a resistor
Emitter is to ground.

Jimbo,
In that configuration, how will that setup only allow voltage to go to the input pin when the arduino is powered up?
Jay

The words you are looking for is parasitic powering or back powering.
When the arduino, or any other chip is not powered if you apply an input voltage to a pin this exceeds the maximum input voltage which has not to be more than 0.5V of the power supply. As the power supply is zero then any normal input voltage will exceed the maximum and damage will occur.
Also the chip can be subject to latch up, that means when the chip is powered up it might not work until the power and input signal are removed and the chip powered up again.
Therefore it is a bad idea to let this happen. If it can not be helped then the inputs must be supplied via a transistor or opto isolator to prevent input voltages reaching the chip.

I found this while looking for the same problem I have with my Frequence counter, but never got i used. It should protect the input from back powering
If you look at the rugged Arduino, he is using a zener diode and a 220 ohm PTC as overvoltage protection.
I was thinking of combining the two approaches
What do the experts say?

 VDD o------o----------.
            |          |
            |          |
           .-.         |
 To PIC    | | 10K     |
           | |         | G
           '-'         l
            |       =======
            |       +     +       Ext.
 Pxx o------o-------o     o----o  Signal
 I/O                |     |
                  S '->|--' D

                     BSS138

I think I need to explain the setup a bit more. Each skull has 2 RGB LEDs and all 4 LEDs are powered by PWM pins on the Arduino (as I use yellow for the blinkers so I needed to be able to alter the power going to certain legs of the LED). So the outputs occupy the PWM pins. The 12v input from the headlight, brakes, directional, and reverse lights occupy A1-5. The problem I am having with the NPN transistors is that the arduino input pins are the load in my scenario. It is very confusing for me.
Jay

Have you read the datasheet ?

It’s explained inside page 75 for ATMega328 → protection diodes

forum.png

68tjs
The issue isn't with running the LEDs. that's a piece of cake. The 7805 VRs are also bringing the power down to 5V nicely. The issue now is how to use a NPN transistor to trigger an input pin. I believe that I have found at least 1 other place where someone worked it out to the same thing I said earlier, so I will go with that and hope for the best.
Jay

The issue now is how to use a NPN transistor to trigger an input pin.

Simple

input pin.pdf (14.7 KB)

68tjs gave the answer as to how the board is being powered up but did not explain it in detail.

The ESD protection diodes on the input pins give a path for a logic high input to reach the Vcc supply rail inside the processor. There are several ways to prevent this from happening. One solution is to switch all the inputs through a set of gates that are only enabled when power is intentionally applied. Care is needed, or maybe a diode in the Vcc line to the gates, since those gates will also have ESD diodes that will energize the Vcc rail. Transistors could be used for as gates and can also do the level translation to limit the input to 5 V. Another solution would be to use a high enough resistor in the Zener diode input limiting circuit that the processor cannot turn on; this is more likely to be temperature sensitive and might vary from processor to processor. Disconnecting all the inputs e.g. via a multi-contact relay would also work but is an ugly solution and still calls for a Voltage level shift.

Alright Mike. I think you’ve given me what I need. I picked up some NPN transistors (getting them on Saturday). Due to the nature of the PDF I found a little hard to distinquish everything, and since I want to make sure I understand properly I have remade it in a paint file to make sure. I’m guessing that my own thought has some serious flaw to it and I’m quite curious. I’m thinking I may need to pick up a book on this stuff, are there any good recommendations?
Jay

Yes the left hand is right ( correct that is ) as to the right hand side I have just woken up and I thought I was still dreaming :slight_smile:
Wikipedia is good for stuff like this look up transistor.

Mike,
The issue that I had was that I believed that the input pin would offer a source for a ground which would completely ignore the transistor. Obviously I need to do some beginners reading into EE.
Jay

No, while the input pin is a diode away from ground the current has to go through the collector to get there. Base to collector is also a diode as is base to emitter. So ground is only one diode away from the base through the emitter but two diodes away from collector via the input pin. So there is no current through the input pin. (apart from the diode leakage current)