Closed jovabra closed 3 years ago
How unstable is it? Is it jumping between 2 close-by values?
The example code uses analogRead
call here directly, without any filtering in software. So any noise in the electrical circuit, or positions right at the boundary may alternate between each other.
There's some techniques that can be used to expand on that - the analogRead, or readCC function itself can be extended with some software filtering. Also, you could define a 'dead zone' that would ignore too small changes, and react to value changes only when it's above some small threshold.
There should be some information on the internet on how to do this, and very likely, there's ought to be some ready to use Arduino library that implements such filtering. Searching for 'arduino analogRead filtering' should be a good start.
gtrainavicius, Thanks, I was actually checking AnalogRead, readCC and others. Now a curiosity, does it really have to be 10k Potentiometer? Could be 20k, no?
The potentiometer acts as a resistor voltage divider network. 20k would probably work ok. Depending on the speed the ADC is reading, higher resistance values may provide wrong results, as it takes some time to charge up the ADC pin during the sampling phase. Lower resistance values consume more power, but charge the pin quicker. Generally, it looks like it's recommended to have 10k impedance for ATmega inputs, see this discussion:
https://electronics.stackexchange.com/questions/107741/required-output-impedance-for-adc-input
I get it... I figured the 5v Voltage is the same that feeds the Arduino. JUST not.... hahaha. The 5V in the case of Leonardo, will guarantee the stability of the ADC (Digital Analog Converter) Through the sampling voltage that is filtered by RC.
Well, in this case, the Impedance really shouldn't go outside the 10k spec, or less. There is probably my problem. Thank you so much, gtrainavicius, forum sharing, it was great.
Cheers! :)
potentiometer floating, unstable, using code midictrl.ino what can be wrong? Leonardo plaque. Thanks