Closed simtcrom closed 2 years ago
Could you explain what behavior you expect from your potentiometer? What happens right now is that your potentiometer has a scale running from 0 to 1023. As long as it's < 400 it will keep sending the command to increase the heading bug and as long as it's > 600 it decreases the heading bug. This will result as you mentioned in the heading bug only not increasing at the 400 - 600 range (somewhere in the middle). A rotary encoder might be a better fit for your needs. The potentiometer has a fixed scale (fully open to fully closed). A rotary encoder can infinitely turn in either direction and registers the increments/decrements in steps. I just spotted that the code in this article (the library part) isn't fully updated yet (on it as we speak) but it shows how it works and how you can implement it yourself https://www.bitsanddroids.com/back-to-basics-dual-concentric-rotary-encoders/. It's aimed at dual concentric rotary encoders but the library used in that article works best. https://www.bitsanddroids.com/back-to-basics-rotary-encoders-in-mfs2020/ This is for single rotary encoders that just explains the basics. The dual-concentric article works better in my opinion.
A rotary encoder might be a better fit for your needs. The potentiometer has a fixed scale (fully open to fully closed). A rotary encoder can infinitely turn in either direction and registers the increments/decrements in steps. I just spotted that the code in this article (the library part) isn't fully updated yet (on it as we speak) but it shows how it works and how you can implement it yourself https://www.bitsanddroids.com/back-to-basics-dual-concentric-rotary-encoders/. It's aimed at dual concentric rotary encoders but the library used in that article works best. https://www.bitsanddroids.com/back-to-basics-rotary-encoders-in-mfs2020/ This is for single rotary encoders that just explains the basics. The dual-concentric article works better in my opinion.
Thank you very much, that make sense. I will procure rotary encoder and test. If you could also please explain the wiring of rotary encoder. Is below the correct method?
It's all explained in the article. But your image should work.
Hello,
I have used wired potentiometer as below to ESP8266Nodemcu
Middle pin - A0 Right pin - 3V3 Left pin - GND
I flashed below program
include
BitsAndDroidsFlightConnector connector = BitsAndDroidsFlightConnector(); void setup() {
Serial.begin(115200); pinMode(0, INPUT); }
void loop() { int value = analogRead(A0); if(value < 400){ connector.send(sendHeadingBugInc); delay(200); } if (value > 600){ connector.send(sendHeadingBugDec); delay(200); } }
When I turn the knob of potentiometer, heading increases. But it never stop increasing, till I bring back the knob to middle.
Could you please help me to modify the code, so that it can be used to increase/decrease headingbug ?