Go Down

Topic: looking at analog inputs with Serial Monitor (Read 307 times) previous topic - next topic

I am using the serial monitor window to read the analog inputs of my UNO R3 using a simple sketch that is just looking at analog pin 0. There are a couple things I don't understand. I am new to arduino so maybe someone can help me understand. Nothing is connected to the arduino but the serial monitor is giving values of around 300. When I connect a wire from analog pin 0 to GND the value goes to 0 which seems to be expected behavior. I don't understand why it is giving a value of 300 when nothing is connected. Shouldn't it give a value near 1023? Also when I removed the wire from analog pin 0 to GND, the values being printed into the serial monitor window took about 4 seconds to return to the original value near 300. I don't understand why this is so slow. Is it supposed to work like this?

robtillaart

Quote
Is it supposed to work like this?

yes, these are called floating lines. The ADC(analog digital convertor) just reads noise which can be any value
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

LarryD

Quote
took about 4 seconds to return to the original value near 300

A charge is slowly building up until it gets to a steady state value. The i/p is a high impedance/resistance so noise in the surrounding circuit is effect your readings.

When you write your sketches you initialize variables so you don't have undefined values in them, hence you avoid bugs or errors.
When you hook up to i/ps and o/ps you connect hardware to them so they are in a way initialized i.e. they aren't at some unknown level of voltage.  These can be external pull up or pull down resistors, internal pull up resistors, sensors,  switches etc.
The way you have it in your schematic isn't the same as how you have it wired up!

liudr

Try touching the pin with your finger you will see the number change. Unless you connect a sensor or something to the channel, it will read random numbers.

terryking228

Two easy tests:
- Hook the wire to 5V you should see 1023
- hook the wire to 3.3V you should see about 700 or so/
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Go Up