problem with analog input in Arduino Uno R3

I have an Arduino Uno R3, I have a problem with the analog input pins and the analogRead() function, when I use the function to read any pin of the analog input pins (A0 - A5) with no wire connected to it, I expect to get 0 as a result, but I usually get a result from 250 to 350, I use this instruction: Serial.println(analogRead(0));

I also tried some things crazy like: Serial.println(analogRead(18)); and for my surprise I still get the same result between 250 and 350!!

Please tell me is that normal? What is the mistake I do? Or is my Arduino board defected?

Thanks a lot for help

when I use the function to read any pin of the analog input pins (A0 - A5) with no wire connected to it, I expect to get 0 as a result,

why? It's perfectly normal.

AWOL:

when I use the function to read any pin of the analog input pins (A0 - A5) with no wire connected to it, I expect to get 0 as a result,

why? It's perfectly normal.

but I don't get the 0, I get about 300!!

Yes, that's perfectly normal. Connect it to ground if you want it to read zero.

aehb:

AWOL:

when I use the function to read any pin of the analog input pins (A0 - A5) with no wire connected to it, I expect to get 0 as a result,

why? It's perfectly normal.

but I don't get the 0, I get about 300!!

Your expectation are wrong. A analog input pin with nothing wired to it is said to be a 'floating input pin' condition and will not read zero counts as the very high impedance of the input pin will be influenced by electrical noise. To test out a analog input pin wire it to ground and then it should read a 0 count value, then wire it to the 5V pin and it should read 1023 count value. If it does both then it's a functional analog input pin.

Lefty

AWOL: Yes, that's perfectly normal. Connect it to ground if you want it to read zero.

Yes this works :) thanks a lot and I'm sorry, I'm just a hobbiest

I'm very happy that my Arduino is ok :) I thought that it had some defect

Do you guys happen to know why none of my analog sensors work with a 10k resistor going to ground.I follow the examples specifically and all i get is a 0, and then i take the ground wire out and i then get a bunch of random fluctuating numbers thanks

TWeiss33: Do you guys happen to know why none of my analog sensors work with a 10k resistor going to ground.I follow the examples specifically and all i get is a 0, and then i take the ground wire out and i then get a bunch of random fluctuating numbers thanks

That is perfectly correct behavior. Explain what you expect it to read in those two conditions. And what 'example' are you speaking of?

aehb: I'm very happy that my Arduino is ok :) I thought that it had some defect

You have just demonstrated one version of a capacitance sensor or proximity switch - one of the more useful things you can do with an Arduino or other CMOS (as almost all are) MCUs. There are libraries to do this.

TWeiss33: Do you guys happen to know why none of my analog sensors work with a 10k resistor going to ground.I follow the examples specifically and all I get is a 0, and then I take the ground wire out and I then get a bunch of random fluctuating numbers thanks

Negligible information there.

What sensors? Why would you have a 10k resistor going to ground? What are you trying to do? Diagrams?

Sorry, I read over this tutorial on the Arduino website ( http://arduino.cc/en/Tutorial/AnalogInput ) and instead of a photo resistor i used a pressure sensor like the one seen on this page ( https://www.sparkfun.com/tutorials/389 ). I then just had the Arduino board take the sensor value and print it to the serial monitor. I noticed that the numbers are all wacky, but when i do lightly tap the sensor the value jumps to 1023 and then slowly trickles down by 50 to its original number and then fluctuates again. I have used these things before, i have done this programming before and got it to work with the same equipment. Its frustrating how elementary this seems but yet I cant get it to work. I am not sure if this means anything but i did notice that I can burn a new bootloader on to my ATTINY devices but i can not burn the bootloader to my R3. Not sure if i am supposed to be able to or not but i thought i may as well throw it in there. All i want the arduino to do is print the pressure sensors numbers on the serial monitor. It is printing numbers but like i said before the numbers are very wacky Thanks for the help!

Try a lower value resistor than that 1M?. (Anybody else think that's too high?) How about 100K (brown-black-orange)?

tried both, neither worked. the pin keeps registering out as a 0 every time i throw in the resistor to ground no matter what type of resistor i use.

TW33, Post a good quality photo of your wiring. It may help to stick the pressure pad to the desktop with a "tape ball".

Sorry it took me a day but i attached 3 pictures below of the connections. Ignore the shift register, and i soldered some yellow wire on the end of the pressure sensor to make it easier to use. That is not the problem though because i tried using my other pressure sensor which has nothing soldered to it and that one does not work either.

forgot the pics haha
had to use word because it would not let me uploead the jpg

arduino pics.docx (657 KB)

TWeiss33: forgot the pics haha had to use word because it would not let me uploead the jpg

I don't have a recent version of Word, so I cannot open DOCX. I upload JPG as attachments here all the time. Maybe the pic you were trying was too big. Try a reduced version of it or put it on flickr or other photo hosting site and post a link.

Hang on, are you not an engineer? Why would you use “Word” anyway?

Open Office.

Paul__B: a) Hang on, are you not an engineer? Why would you use "Word" anyway? b) Open Office.

a) I think I'd rather sell hot dogs than futz around with Linux etc.

b) If it was important to me then I'd d/l it a usb stick and run it to that computer in the other room and I'm nowhere near that motivated.

Did I mention Linux?

It is the case that I use Linux on all machines which do not need to run my practice bloatware, but I mentioned Open Office, not Linux. :smiley: