Potentiometer "Debounce" values?

Hi!

I am a new user at Arduino and am currently practicing programming for a potentiometer.

I get values that can be shiften between 2-3 numbers every now and then. How do I solve this? Any ideas?

I have looked at arduino forums, youtube etc.
Here is my coding:

You could have a look here at various solutions: Hysteresis

2 Likes

Make multiple measurements and average them.
Add a 1uf cap across the pot.

2 Likes

Any good tutortials/description to do this?

The root cause of the problem might be noise/mains hum being picked up by your wiring.

Do you have long wires going to the potentiometer?

No, Im using an ESP32 T-Display S3 with a potentiometer.

I have moved your Topic to Programming Questions....Please try not to post in Uncategorized again, If you are unsure about the categories refer to this guide or to the stickies for each category.

Thank You.

Another very easy and effective smoothing technique is to use a leaky integrator, technically a form of low pass filter.

See the entire thread of this post

Google "leaky integrator" or search further on these fora.

HTH

a7

1 Like

Not sure dial is the correct word; the carbon 'dial' is not perfect, and gets worse over time. As @2112 say, you average several readings.

Debounce is used for buttons and other type of mechanical contact switches.

Btw, welcome to the forums.

1 Like

Post the code here and your goals and I'll fix it up for you and explain each fix so you learn and understand

Dividing a standard 270 degree sweep potentiometer into 360 discrete units, as you appear to be doing, is anyway going to be difficult. If you really need that resolution, then a rotary encoder is likely to be a better solution.

I actually solved it. What I did was first taking the analogRead and then creating a float called mappedValue for scaling the numbers. And also creating a new float called finalvalue with "/=" and got a more specific measurment.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.