I'm trying to use a pentometer with my Arduino Mega, but analogread only seems to return the 8 lower bits, ignoring the first two. As I turn the pentometer it goes up to around 256, the jumps back to 0. It does this four times. I've tried multiple pentometers all different ports, but it's the same problem.
The Knob servo example shows this problem, as does simply sending the values to the computer over serial. Is there something physical I'm missing (like adding a resistor)?
My code (I commented out the servo code):
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
myservoB.attach(9); */ // attaches the servo on pin 9 to the servo object
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
/* val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)