Go Down

Topic: Arduino Uno - Analog Input: Random power readings. (Read 1 time) previous topic - next topic


Feb 28, 2013, 05:44 am Last Edit: Feb 28, 2013, 06:32 am by Coding Badly Reason: 1
Hello, I'm currently working with my arduino uno, and i noticed sections of my script triggering when I had not intended for them to be triggered, then i tracked the issue to my analog input.

the analog inputs A0 through A5 are all displaying absolutely random readings.

Here's my output:

and my code:

Code: [Select]
int x = A1;
void setup()

void loop()
 int var = analogRead(x);

I used this code to test my theory of these random readings, and sure enough it was true.
This is an issue.
My trigger uses a the analog inputs to read the power from the 3.3V power source on the arduino.
Running this script, 671 is often printed, and that's causing my script to fire when i do not want it to.

Does anyone know why this is happening?

The A1 port is totally disconnected from anything, and i've even lifted the Arduino Uno in the air so it's suspended by it's cable to the computer, yet these random readings are still there.

Moderator edit: [code] [/code] tags added.


Floating Input. Completely expected. If you want it to default to a reading of 0 or 1023, you need a pulldown/pullup resistor, respectively.


I'm quite new to this, and I have not studied any of this in any sort of class. (I'm 16 also)

What's a pull-up/down resistor?

Is this a reliable page?


That's the general idea.

The A1 port is totally disconnected from anything ...

It therefore won't give a reading of zero, it will give an undefined reading.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics


Yes and lookup pull-downs too.... Most handy to be able to 'preset' inputs to known states... which is what it is all about, that and understanding when it is necessary and when not... A 'hint', better safe then sorry as you found out... start with 100 K and go as low as necessary to keep the open pin quiet or not reporting change that isn't there...

--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard


I got it working, thanks guys!

You've all helped me greatly.
My understanding of the arduino and circuits increased much.

Farewell for now!

Go Up