Input pin too Sensitive?

For makers who have purchased an Adafruit Starter Pack, get help with the tutorials here!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
jintachi
 
Posts: 2
Joined: Sun Dec 05, 2010 1:57 am

Input pin too Sensitive?

Post by jintachi »

I'm running the following simple program:

Code: Select all

#include <SoftwareSerial.h>

void setup()
{
  pinMode(2, INPUT);
  Serial.begin(9600); // set up Serial library at 9600 bps
}

void loop() {
    delay(1000);
    int buttonState = digitalRead(2);
    Serial.println(buttonState);        
}
And to my dismay, with nothing connected to the arduino but a cable at pin 2 I get output that looks like: 1 1 1 1 0 0 1 1 0 0 0 1 0 1 0
Essentially HIGH and LOW occur at random or are affected by my movements (like scratching my head). Is my arduino broken?

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: Input pin too Sensitive?

Post by adafruit_support_bill »

You need a pullup or pulldown resistor. Check Arduino tutorial #5. http://www.ladyada.net/learn/arduino/lesson5.html

jintachi
 
Posts: 2
Joined: Sun Dec 05, 2010 1:57 am

Re: Input pin too Sensitive?

Post by jintachi »

Thanks.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Starter Pack”