I'm having a problem with my potentiometer.
The purpose is to change the color of an RGB led strip.
When I turn the potentiometer it works fine, but when it isn't turned there is not a constant voltage and therefore the led strip keeps flickering. Another problem is that the voltage won't return to zero.
I think I need to put a resistor somewhere in between the potentiometer and the arduino, but I have no idea if this is correct, and if so where i should put it and how much resistance it should have.
rgb_tafellicht.ino (2.62 KB)
Th combination of resistor and potentiometer has to form a calculated function.
You cant just use any random values.
They work as a VOLTAGE DIVIDER.
In the examples sketches is one called "AnalogReadSerial" and I suggest you use that as a second step in getting your project running as it will just read the values produced to the serial monitor so you can see that it covers the range you need for your final project.
Normally you would just use a 10K pot without a resistor.
If you dont have a 10K pot then you would need a lower value with a resistor to bring it into the 10K range but you may then have to MAP the value too.
I indeed have a 10K pot, so I won't need a resistor.
I found out i can use smoothing code to make i flectuate less.
But I still don't know how to let the pot return to 0 volt, since atm the lowest value i get is around 0.1V
Fluctuation can often be caused by a poor power supply so you would need to make sure you are good in that area.
Dont forget that a string of LED's often need thier own PSU supply too especially RGB strips if they are neopixel types.
Often a 0.1uf cap from the analog input to ground will help to stabilize to voltage reading.
Cheap pots can have problems - eg
- poor (intermittent) contact at the wiper
- large 'unswept' region at the ends
- large wiper resistance.
You can improve 3 with smoothing - try a 100nF capacitor from wiper to ground , and 2 by using the map() function to get the range you want. If 1, chuck it away.
Allan