Go Down

Topic: Why are my analog inputs values floating? (Read 2424 times) previous topic - next topic


Nov 25, 2008, 05:31 am Last Edit: Nov 25, 2008, 05:36 am by scootabug Reason: 1
Hi again,

Using Nano, I'm measuring the inputs of some analog pins.

Sometimes nothing is connected to them (while I'm debugging).  When this is the case, the values returned from analogRead(intPin) on these pins tend to "float".

Does this mean I need to have the analog input pins pulled to ground with a small resistor, or can I enable one of the internal resistors on each pin to stop this from happening?

I'm reading this page and it refers to pullup resistors: http://www.arduino.cc/en/Tutorial/DigitalPins
And it specifies this code:
[font=Courier]digitalWrite(pin, HIGH);[/font]       // turn on pullup resistors

Does that means I tun on a pulldown resistor by using digitalWrite(pin, LOW);?


Thanks for your help.



Actually I now realise that I can't do a digitalWrite() to an analog pin.  Or can I?


If you are using them as analog inputs don't use a pullup.

I don't know how enabling the pullup interacts with analog inputs.

The  ATmega does not have a pulldown.

The analog pins can also be used as digital pins, so the digitalWrite() call is potentially valid.



I didn't try the digital write but I did try analogWrite(0) to it...really didn't help.  Pointless trying anything else if the ATmega doesn't have any internal pulldown resistors...

I've put a 150k resistor on the analog input to pull it to ground when there's nothing coming into the input.  It seems to be reducing the input (I can only get to 1016 or so?) range, probably not wired up the way it should be...I'd have no idea realistically.  In reality I might not need this at all, just airing my issues as they arise.

Thanks for the help...


Just a reminder that when you do digitalWrite(0) and analogWrite(0) you are dealing with two different pins...  This has tripped me up before.



th reason you only get 1016 maximum is because you are dividing your input between the pulldown resistor and the internal resistance of the analog pin.

Go Up