Hi,
I have what should be very simple code, and yet I seem to have an issue. the ADC value (as the subject suggests) is stuck at 1023. I’m running an Arduino Pro 5V 16 MHz. I’m changing the voltage with a multimeter, and yes, it is wired properly, I can see the analog voltage change on my multimeter, but not on the serial output. I’ve tried multiple ADC pins, I’ve tried setting sensorPin to 5 instead of A5, etc… and no dice.
int sensorPin = A5; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int speed = 0;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
Serial.begin(9600);
}
void loop()
{
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
speed = map(sensorValue, 0, 1023, 83, 180);
//figure out what values for spinning should be
myservo.write(speed);
Serial.println(sensorValue);
}