0

Ananlog Read question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Ananlog Read question

by Einsteins Circuitry on Sat Feb 09, 2008 1:14 pm

The other day I was fooling around with my Arduino and discovered something that I'm not sure about. I was experimenting with the analogRead function. Here is my code...

int inputPin = 2;
int ledPin = 13;
int val = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
val = analogRead(inputPin);
if (val > 900) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}

When I touched the wire coming out of the Analog In pin #2, the LED (pin 13) turned on! I wasn't touching anything other connection on the board. I can't figure out why when you touch that pin, it gives a value usually above 900. Why? I did some research and I still can't figure out why.

Help would be greatly appreciated!
Einsteins Circuitry
 
Posts: 4
Joined: Sat Feb 02, 2008 1:27 pm

by adafruit on Sat Feb 09, 2008 1:39 pm

the human body has some stored charge, so if an analog pin is floating you can actually make the value change by touching it!
its a little risky tho, if you have too much charge (static) you can fry the pin :(

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Please be positive and constructive with your questions and comments.