Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Wiring Hardware >> Troubleshooting >> analogRead problem?
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1222451407

Message started by jlubeck on 09/26/08 at 17:50:07

Title: analogRead problem?
Post by jlubeck on 09/26/08 at 17:50:07
Hi! I started messing around with a wiring board, and I wanted to use the analog input pins, but when I use analogRead(), even with nothing connected to the board, just the USB, it's giving me random values. I believe it should be giving me all 0 when nothing is connected?

with just this code:

Code:
     

int inpin = 0;
int val = 0;

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

void loop() {
 val = analogRead(inpin);  // read the value of analog pin 0
 Serial.print(val);
Serial.print(" ");
}


This is what the serial monitor is giving me:

Code:
0 0 0 0 0 2 4 17 38 66 86 90 77 52 9 6 0 0 0 0 0 1 9 15 43 69 89 91 76 48 9 2 0 0

and so on..
any ideas?

Title: Re: analogRead problem?
Post by barragan on 09/26/08 at 18:08:26
hi, thatīs not a bug, please read this: http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1199454633

Title: Re: analogRead problem?
Post by jlubeck on 09/26/08 at 18:20:29
thanks barragan!
I never said it was bug, just wondering why it was happening ;)

Thanks for that thread, I'll keep asking questions there

Cheers!

Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.