6 button RGB controller using Arduino
In this instructable we will learn how to use 6 buttons to control the color of an RGB LED with the use of an Arduino Micro Controller. This is a fun and easy little project that should take you no more then 20 minutes to finish.
Step 1: Connecting an RGB LED
Before we connect the LED to the breadboard we first need to identify the Anode and Cathodes. If you pick up your LED at a retailer there should be a diagram on the package indicating the Anode and Cathode as well as which pin goes to which color. As with every LED the longest pin is the Anode. On my LED the pins are arranged as Red Cathode, Anode, Blue Cathode, and Green Cathode. We can now plug the LED into the breadboard.
Another important fact about LEDs is the Anode always has the voltage going into it and the Cathode goes to ground. So we will want to place a jumper from the Anode to the 5V rail on the breadboard. Next we need to add resistors to the cathodes. Resistors are needed to limit the current flowing to the LEDs. Since we are connecting the LED to 5V we need to limit the current going into it otherwise we could burn out the LED. If we go from one cathode to the next plugin the same resistor between it and ground we can see that the different colors are not shining at the same intercity. In the pictures i used a 220 Ohm resistor to demonstrate the differences in brightness. Its easy to see that the Red is the dimmest. The difference in the Blue and Green are hard to tell in the picture but the green is actually brighter. So we will use a 220 Ohm Resistor on the Red, 470 Ohm on the Blue and a 1k Ohm on the Green. We want to plug them in with the LED and on the other side of the board. Finally we will connect some longer jumper wires to the resistors.
Now we will take the wire on the Red LED and connect it to pin 9 on the Arduino. We put the Blue LED wire on pin 10 and the Green LED wire on Pin 11.
Step 2: Connecting the 6 buttons
Now we move onto the buttons. We want to place them on the board with 3 on the top half and 3 on the bottom half. We want one leg of each button tied to ground with a jumper wire.
On the 3 lower button we want to place a jumper wire on there other leg to run up to the top side of the bread board. This will help keep the wiring good and tidy. Now we can take a 6 good lengths of jumper wire and attach them to the other leg of all the buttons. I used a piece of ribbon cable to help keep the wires organized.
The buttons can be wired to ground and don’t need a pull up resistor if you are using a Arduino Nove or newer since they have built in pull up resistors.
Now we need to pay attention to what wire we are handling as we connect them to the Arduino. The wire will go in as follows:
- Upper Left button to Pin 2
- Lower Left button to Pin 3
- Upper Middle button to Pin 4
- Lower Middle button to pin 5
- Upper Right button to Pin 6
- Lower Right button to Pin 7
Make sure you have a couple of jumpers going from the 5V and Grd pin on the Arduino to the 5V and ground rails on the bread board and we are ready to write a sketch to control this mess.
For more detail: 6 button RGB controller using Arduino