RGB LED and Potentiometer Relationship

RGB and Potentiometer

This Project aims to explore whether the colour of an RGB LED can be altered using input from a potentiometer.

Research

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 achieveduntitled.png

http://www.brighthubengineering.com/commercial-electrical-applications/47625-potentiometers-explored-construction-and-working-principles/#imgn_1

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.

Experiments

I wrote this small bit of code to illustrate how a potentiometers variable resistance can be used to alter an RGB LED:

https://create.arduino.cc/editor/JackGormley/a705ebcd-61a2-4248-aea2-bc7411042bd1/preview?embed

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:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s