hey. I've been asked to program a sensor that is regulated by a potentiometer. While most of the design is done, i faced a problem where i kept getting a constant high or low (1023 or 0) for my pot. I disconnected everything but my pot (50k) and tried the most basic tests provided in arduino tutorial. When i connected all three pins( outer pins to gnd and 5v and middle to A0 input), and ran the Serial moniter, I only manage to get 0. For some reason, my bottom pin and middle pin seem to be shorted. However when I checked using a multimeter, the potentiometer was functioning perfectly.
The code i used is this
int a=A0;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(a,INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(a);
// print out the value you read:
Serial.println(sensorValue);
delay(1000); // delay in between reads for stability
}
Where do you think my error is? I've checked online everywhere but seem to be getting the same problem. I've tried it on Uno smd version, Uno R3 and Arduino 2560 Mega.
Would someone tell me where I'm going wrong?