RGB and Potentiometer
This Project aims to explore whether the colour of an RGB LED can be altered using input from a potentiometer.
For literature on RGB LED modules, please refer to my other blog post at: https://uwearduino.wordpress.com/2018/02/19/rgb-module/
As for potentiometers, these are variable three-terminal resistors that can increase or decrease their resistance with a manual input. This allows them to manually increase or decrease a fixed input voltage to a variable output voltage.
Potentiometers work by increasing the amount of resistance material between the slider and a power sauce, or decreasing it for less resistance. The following diagram shows how this distance is achieved
As the wiper is turned clockwise, a higher resistance is put between it and the positive terminal, while consequentially less is put between it and the GND terminal.
This video goes more in-depth about the mechanism of potentiometers:
What will happen?
Based on my understanding of both components, the potentiometer can be used to send a variable signal to the RGB Module and with some coding will then be able to alter the values of one of the diodes outputs.
I wrote this small bit of code to illustrate how a potentiometers variable resistance can be used to alter an RGB LED:
In this code i used a map function to convert the potentiometer signal (between 0-1024) to a range that the LED can take (0-255). With this mapped variable ‘colChange‘ i simply plugged it into my setColour() function and ran this in the main loop. The resulting output was an LED that transitioned from a 0 signal (off) being sent to the red LED when the potentiometer was set to 0, to a full 255 red signal being sent when the potentiometer was set to 1024, including all the gradient of colour inbetween. The LED isn’t full red because i also passed a green value of 30 and a blue value of 10 to the LED.
Here is a video of it working: