Hi, I want to receive energy in PIN7 and when it happens I want the led (pin13) to turn ON. if the energy stops the led should go OFF.
I can do that, the problem is that it's not reliable, sometimes i'm not giving energy in PIN7 and it's keeps saying that i'm doing that. Can someone help me pls
The code might not be the best (i'm new) if you have improvements fell free to add them.
And sorry if my english was not the best...
How, exactly, are you feeding energy to pin 7? It sounds to me like you have a "floating input" (Google that). Inputs are very high input impedance. That means that it takes very little energy to make the input change state. Just moving your hand close and away can affect the state. The way to prevent a floating input is to make sure that the input is always in a known state. If you change the pinMode from INPUT to INPUT_PULLUP you will see that the input will always read HIGH when unconnected (no energy) and always read LOW when connected to ground. That is the proper way to wire a switch.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Yes, you shouldn't play with things you don't understand.
But since you will anyway, why not just use an LED to make that connection? When power is going in to pin 7, it will pass through the LED and light up real pretty.