# Noob Circuit in Quest For Understanding

Noob here. Vague understanding of electronics although I am a fast learner so feel free to get technical. I created a simple circuit on a Arduino Uno. No resistors, just an LED and wires. The idea is as follows: If a pin receives current (when I run a wire from the 5v out to pin 11) it activates a small LED that I plugged into pin 13 to ground. Wow, revolutionary I know. The odd thing is that when I attach the wire to pin 11 the LED comes on but when I detach the wire, the LED stays on for 5 seconds or so and then slowly fades out. It also does some even weirder stuff like blinks quickly at random times after detached. Can anyone explain this phenomenon to me?

Here's the code for further understanding.

int Red_LED = 13;
int SwitchPin = 11;

void setup()
{
pinMode(Red_LED, OUTPUT);
pinMode(SwitchPin,INPUT);
}

void loop()
{
{
digitalWrite(Red_LED, HIGH);
}
else
{
digitalWrite(Red_LED,LOW);
}
}

If the input is "floating" - there is nothing else attached to the pin - then when you disconnect it, the voltage on the pin could be anything. If there was some residual charge, it could slowly drain away showing the behavior you see.

It could also just keep the LED on, too.

Thanks for the reply. I'm assuming grounding the input will immediately remove residual voltage?

Correct.

Waving your hands around the input pin will probably make the light turn on too. Floating inputs are weird.

It's easy to see how this becomes an issue when using switches or buttons for input. The solution is to have your switches or buttons connect the pin to ground when pressed. Then, set the pinMode() for the pin to INPUT_PULLUP, which activates a weak internal pullup resistor. That way, the pin will read high, unless the button is pushed.

For information on the care and feeding of inputs, see:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

The idea is as follows: If a pin receives current (when I run a wire from the 5v out to pin 11)

Input pins don't take current, they are extremely high resistance, think of them as purely sensing
voltage. Typical input resistance for any CMOS logic input is in the 10^10 to 10^12 ohm range at
room temperature. For all intents and purposes that's infinite.