Hello!
I am trying to use a 10K potentiometer (looks like the one in this link) for positional control with a Particle Photon (firmware version 2.0.1). The control knob rotates about 280 degrees. When doing an analogRead, I do get values from 1 through 4094 but the issue is that I get 4094 as I get close to 180 degree rotation of the knob and it remains at 4094 from 180 to 280 degrees. I have a few pots and all behave the same way. I’ve tried connecting the pot to all ADC pins on the photon but that does not change the behavior. I’ve tried this with 3 of my photons - same result.
Any thoughts on why this could happen? I need to be able to measure a rotation of ~ 210 degrees for my application.
Here is the code I am using. Any help is greatly appreciated!
int potpin= A1; //A1
int potValue = 0;
int potMappedVal = 0;
void setup()
{
pinMode(potpin, INPUT);
Particle.variable("potValue", potValue);
Particle.variable("potMappedVal", potMappedVal);
}
void loop()
{
potValue = analogRead(potpin);
potMappedVal = map (potValue,1, 4094, 0, 270);
delay(20);
}