r4sby
October 18, 2023, 10:07am
1
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:
6v6gt
October 18, 2023, 10:27am
2
You could have a look here at various solutions: Hysteresis
2 Likes
2112
October 18, 2023, 10:33am
3
Make multiple measurements and average them.
Add a 1uf cap across the pot.
2 Likes
r4sby
October 18, 2023, 11:12am
4
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?
r4sby
October 18, 2023, 11:38am
6
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.
There are lots of different categories to choose from. Choosing the right one is important because not everyone who might be able to help you reads every category. Some questions might reasonably fit in to more than one category but please do not post the same question in two or more different categories. Also, if you have more than one question but the questions are all about the same project then it is usually preferable to keep the questions in one topic. Keeping them together helps get better answers as the answer to one provides the context for the next. Creating the same question multiple times or creating lots of different questions about the same project is against the forum rules and will incur the wrath of the moderators when they see it.
Thank You.
alto777
October 18, 2023, 11:46am
8
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
TBC, those are two diffferent things; @gcjr shares an equation for the leaky integrator.
A leaky integrator can also be written, less efficiently yes, as
value = alpha * value + (1 - alpha) * newReading
Or I guess
avg = alpha * avg + (1 - alpha) * samp
with alpha set between 0 and 1. that parameter determines the rate at which the value converges to constant input.
With alpha at 0.9, for example, the equation reads
take ninety percent of the old value and add ten percent of the…
Google "leaky integrator" or search further on these fora.
HTH
a7
1 Like
ledsyn
October 18, 2023, 11:46am
9
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
6v6gt
October 19, 2023, 7:30pm
11
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.
r4sby
October 20, 2023, 6:00am
12
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
system
Closed
April 17, 2024, 6:00am
13
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.