Hi,
As per the AnalogRead reference, (http://arduino.cc/en/Reference/AnalogRead).
Anaolg inputs fluctuate when signal wire is disconnected.
Is there a way to programatically get around this?
Any advice welcomed.
Thanks,
Graeme.
Hi,
As per the AnalogRead reference, (http://arduino.cc/en/Reference/AnalogRead).
Anaolg inputs fluctuate when signal wire is disconnected.
Is there a way to programatically get around this?
Any advice welcomed.
Thanks,
Graeme.
No, don't disconnect the wire. If you do disconnect it, the input is floating and can read anything.
You could put on a pull-down (or pull-up) resistor with a large value, so you get a known result if it is disconnected. This pull-up (or down) however may affect whatever-it-is that you are reading.
Depending on how important it is ? (I don't see why it should matter anyway if you remove the input connection why should you care what it reads since your code should never be reading an unused input) you can use an analog switch with two inputs, one the input you plan to use, and the other a jumper to ground. Select the input when you are using it and select the ground jumper when you are not. That will guarantee a "0" reading IF you read the input which you should NOT be doing if you are not using it.