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!
@jstobaugh - I do have a follow up question if you don’t mind. The pot reading works fine once I connected it to 3V3 and GND. Pot data pin connected to A1.
I have a servo connected to A5, VIN and GND. As soon as the servo begins running, the pot reading remains stuck at the last value it read before the servo started running. It does not change when I rotate the knob.
I checked the voltage with a multimeter between 3V3 and GND. The reading was 3.3v initially and 3.29V when the servo runs.
Any thoughts on why this could be happening?
Hmm…okay. Both potentiometer and servo are powered from the 3v3 and the VIN pins. Does that matter? As in, do I have to use an external power source for the servo?
Assuming you are using an RC servo I would run it on the 5 volts. You need to verify current draw of the servo and make sure 5 volt input current is higher. Also a capacitor would be wise on the 5 volt connection going to the servo.
Yes, it is an RC servo and I’ve connected it to VIN which I believe is 5V.
Do you think not using an external power source for the servo causes this pot behavior?
Your continous() function is not returning an int value while promising to - that is an absolute no-go!
With 2.0.0 this will definitely cause an SOS+1 panic (hard fault).
@ScruffR - Thank you. That was it. I had no idea it could result in such a strange behavior. Pot reading changes now with the shaft even with the servo running.
Great community here. Thanks again!