Pages: [1]   Go Down
Author Topic: looking at analog inputs with Serial Monitor  (Read 287 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 223
Posts: 13876
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Tillaart

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

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2805
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 74
Posts: 7256
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1926
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Pages: [1]   Go Up
Jump to: