1int analogPin = 3;// potentiometer wiper (middle terminal) connected to analog pin 3
2int val = 0; // variable to store the read value
3
4void setup() {
5 Serial.begin(9600); // setup serial
6 analogReference(EXTERNAL); // the voltage applied to the AREF pin (0 to 5V only)
7 // is used as the reference.
8}
9
10void loop() {
11 val = analogRead(analogPin); // read the input pin
12 Serial.println(val); // debug value
13}