Analogue input acting strange.

Hi guys, I uploaded the example program with the potentiometer on the board. Works fine.

I disconnected everything except the USB cable from the board but my arduino says prints numbers around 300-400 on the serial monitor.
Why is this happening? Electrons going through air or something silly like that?

Analog pins float if they are not connected to anything.

Don't worry about it :stuck_out_tongue:

You can enable internal pull-up resistors if you want them to default (to high) when everything is disconnected.

You could also use an external pull-up resistor to pull it low (0) when nothing else is connected.

How do you mean "float"?
And why isn't this pullup resistor set up as a default already?

Float = picks up noise from surrounding environment - a fact of life with extremely high impedance circuits like an arduino input.. The internal pull up resistor isn't enabled by default because you may wish to use an external pullup or pulldown resistor, a pullup resistor will also interfere with any external circuit you wish to connect to the analogue pin. Its also inappropriate if you decide to use the analogue inputs as digital outputs).

This page explains how to enable a pin's internal Pull-Up.