Reading Analog Signals

The Arduino can read analog signals from potentiometers, photoresistors and other sensors whose voltage changes with signal intensity.

The analog voltage must be in the range of 0 to 5 V.

Connect the variable voltage (check that it can never go over 5 V) to one of the six Arduino analog input pin, which are numbered 0 to 5 and are located on the other side of the board from the digital I/O pins. Here is a sample program, copied from the Arduino Language Reference, that will print the analog value on the PC screen.

int val;
void setup() {
  Serial.begin(9600);     //  setup serial
void loop() {
  val = analogRead(3);    // read analog input pin 3
  Serial.println(val);    // print to screen