Pages: [1]   Go Down
Author Topic: Lilypad USB Pin 9 goes high without being connected in a circuit  (Read 17955 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2568
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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?"

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 631
Posts: 34505
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

ou need pull up or pull down resistors, see:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27352
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the internal pullup, and look for a low instead:
Code:
pinMode (9, INPUT_PULLUP);

then
if (digitalRead (9, LOW){
// do whatever
}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: