Go Down

Topic: Lilypad USB Pin 9 goes high without being connected in a circuit (Read 18753 times) previous topic - next topic

womtom

Hello

This is my first arduino project and I was trying to test a simple program that uses pin 14 as an output to an LED and Pin 9 as an input for a button.  The program simply waits for pin 9 to go high when the button is pushed. My issue is that i connect the LED from pin 14 to the negative power port, and when I just touch pin 9 with either my bare finger or a piece of stripped wire the pin acts as if it has gone high and runs the program to blink the LED for roughly 5 seconds and then stop.  So I know that my program sort of works, but I am unsure why pin 9 goes high when it is not connected to the negative port on the board and is activated when touched by a finger or wire in my hand.  If need be I can post my code on this thread.  Any help would be much appreciated.

-womtom

Runaway Pancake


but I am unsure why pin 9 goes high when it is not connected to the negative port on the board and is activated when touched by a finger or wire in my hand.


You're coupling "stray AC" (it's all around us, everywhere) into the input pin.
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"


charliesixpack

Your body acts as a big capacitor and it can be charged to a quite high voltage.  You have no doubt noticed that you can produce a spark by touching a grounded object after you have walked across a rug.

leibniz81

As Grumpy-Mike says add a pull down or up resistor to avoid the false high states

CrossRoads

Use the internal pullup, and look for a low instead:
Code: [Select]

pinMode (9, INPUT_PULLUP);

then
if (digitalRead (9, LOW){
// do whatever
}
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up