Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTroubleshooting › analogRead problem?

Page Index Toggle Pages: 1
analogRead problem? (Read 2844 times)
09/26/08 at 17:50:07

jlubeck   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 6
*
 
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?
 
IP Logged
 
Reply #1 - 09/26/08 at 18:08:26

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hi, that´s not a bug, please read this: http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1199454633
 
IP Logged
 
Reply #2 - 09/26/08 at 18:20:29

jlubeck   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 6
*
 
thanks barragan!
I never said it was bug, just wondering why it was happening Wink

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

Cheers!
 
IP Logged
 
Page Index Toggle Pages: 1