Arduino Uno board potentially outputting noise

Hello,

I currently am using an Arduino Uno Genuine board and running a code for testing. When running, without anything attached to my board, it is outputting values and I am unsure of how it is outputting values with no input values.

The serialprint.ln lines are what are outputting values, and I am unsure of why it is outputting values when no input is going on.

I believe that it may be noise values but how much range does noise have values for?

Attached, is my code.

averagingideaALL3.ino (1.85 KB)

When nothing is connected to a pin set to INPUT mode, the pin is floating. This means it can be in any state and that state can change from any small electromagnetic interference. This is why we attach a resistor to input pins so that they are pulled to a known state. The Arduino Uno even has internal pull-up resistors you can turn on via pinMode(pin, INPUT_PULLUP).

More information:
External pull-down resistor: https://www.arduino.cc/en/Tutorial/Button
Internal pull-up resistor: https://www.arduino.cc/en/Tutorial/InputPullupSerial

Indeed - a conductor (wire, trace, or the pin itself) connected to a high impedance (input) pin will pick up random noise - if the conductor is shaped and sized precisely, it's called an antenna. Otherwise, it's called a floating pin, and they're a bad thing.

Good design (per Atmel datasheets) calls for setting all unused pins INPUT_PULLUP (or using an external pullup or pulldown) - this reduces power consumption by a tiny bit (though I have pretty much never seen anyone in Arduino land do this).