Our Cookies Policy
To make full use of www.electromaker.io, enjoy the personalised features and ensure the websites works to its full potential, your computer, tablet or mobile phone will need to accept cookies.
Our cookies don’t store sensitive information such as your name, address or payment details: they simply hold information about how you use our site so we can improve your experience and resolve any errors.
If you’d prefer to restrict, block or delete cookies from www.electromaker.io, or any other website, you can use your browser to do this. Each browser is different, so check the ‘Help’ menu of your particular browser (or your mobile phone’s handset manual) to learn how to change your cookie preferences.
Here’s a list of the main cookies we use, and what we use them for:
Electromaker – Login session
Google Analytics – Analytics
Twitter – Twitter Feed
Each web browser handles cookie management differently, please follow instructions for your chosen browser:
In a nutshell, it transforms a adjustable amount of the voltage (changes by twisting the rotor) to the Arudino analog input pin ( Vout ) this link explains the topic even further.
Pot voltage dividerArduino analog input pins
Connect the pot as illustrated in the image, connecting the outer terminals on either 5v or GND doesn't matter at all, the most important connection is the middle terminal, which goes to the analog input pins.
You obtain the 5v and GND from the Arduino pins.
I'm using the Orange for the 5v ( instead of Red ) to make easier to differentiate between power and signal lines
Potentiometer (Pot.) Connection
Repeat this connection for the 3 pots for each color.
I want to keep the connections as tidy as possible so I'll connect the pot for the Red color on A0, Green on A1 and Blue on A2.
1-3 Connecting the RGB LED
The RGB LED uses the same concept of the conventional LED ( diode ) the magic happens because it contains 3 LEDS beside each other, when the light from those LEDs fall on your retina they represent different colors because you view them as a single combined color.
Since we have 256 value for each PWM output and 3 pins that represent Red Green Blue, we have a total of 256 * 256 * 256 colors which is 16,777,216 colors (almost 17 Million).
The RGB Led is connected the same way you'd connect a normal LED but you repeat the work 3 times.
Red LED and ground connected
The final output should look like, I connected the Red value on the lowest pin number in either the input and output pins, just to keep things simple in code.
Don't forget to connect the 330 Ohm resistor because I made this mistake and got my Red LED burnt out electricity won't do much work to get an LED burnt, so take care.
Full circuit breadboard view
Now we have a complete circuit, the code is really so simple and straight forward.
The code of the Arduino does those simple tasks in a sequential manner.
In the Setup
Set the mode of 3 analog input pins to input
Set the mode of 3 pwm (analog output) pins to output
In the Loop
Read the value of the pot. using analogRead function
Map the value from the analog pin to a matching PWM value using the map
Write the PWM value to the analog pin using analogWrite function
The code is available below.
my final output don't forget that I burnt the Red LED : -it's connected on the first pot-
Now you have the ultimate color generator with 17M colors! congrats!!
Respect & Share the project it if you like it :)
Check out my other tutorial about making an 2 wheel drive robot using 1Sheeld.
RGB LED Game code
Connect the LED pins according to the pins in outRGB array and the sensor pins according to inRGB array