6

I have tried measuring the analog pin value using the provided standard sketch in the Arduino IDE. However even when there is no connection to the pin, it prints out random values. Is there anything that has to be taken care of?

I have a FSR sensor connected from 5V+ to analog pin 0

Casper Marcussen
  • 133
  • 1
  • 3
  • 7

4 Answers4

10

No connection giving you random value is completely expected. The pin is floating, and may or may not have a charge on it at any time, giving random values.

Attach the analog input to ground - it should return a number approaching zero (within the accuracy and noise of the ADC).

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82
  • Thank you very much for the answer, following this tutorial i got the right reading: http://www.ladyada.net/learn/sensors/fsr.html another question then, why is it necessary to connect the fsr to the ground? – Casper Marcussen May 17 '10 at 18:05
  • 1
    It is not. The attach to ground is a test to determine if your analog input code is doing what you expect. – Yann Ramin May 17 '10 at 20:26
5

You have to use "Pull-up" or "Pull-down" resistor. Read here about this circuit: http://www.ladyada.net/learn/arduino/lesson5.html

meneldor
  • 223
  • 1
  • 8
1

Providing a path of higher resistance to ground ensures that when that portion of the circuit is open, the static electricity remaining in the portion connected to the pin gets grounded. It also splits the voltage between both paths to allow you to properly throttle the voltage to the pin.

diatrevolo
  • 2,782
  • 26
  • 45
0

The same problem arise to me , What you have to do is change the" Serial.begin(9600);" To "Serial.beigin(115200); Now it is showing exact zeroes without any input source.