2018-02-02 16:27:01

LEDs are great. But with any activity there comes a point area aflame is artlessly not enough. For these cases an RGB (Red, Green, BLue) LED is the answer.
With an RGB LED you'll be able to aftermath any colour afterglow your affection desires.
At aboriginal application an RGB LED seems absolutely complex, but it absolutely bound becomes bright that its no added difficult than authoritative one of their individual colour adverse parts.
What follows is a quick adviser to get you started authoritative an RGB LED aboriginal with affairs again with an Arduino microcontroller.
Step 1: Parts
Only a few locations are required.
A accepted anode RGB LED is annihilation added complicated than three one colour LEDs (one red, one green, and one blue) housed in a individual package.
Rather than accepting 6 leads (a cathode and anode for anniversary LED) it has alone 4 one cathode for anniversary colour, and one accepted anode. (see the schematic diagram below)
A accepted anode RGB LED is the a lot of accepted type. It is a lot of frequently begin in either a 5mm ball admeasurement or as a 5mm pirahna anatomy factor.
Current Attached Resistors (270 ohm) (red-purple-brown)
Most LEDs are advised to plan with a voltage amid 1.5v and 3v. As a lot of microcontrollers (including the Arduino) accomplish on 5 volts a accepted attached resistor is required.
Consult your LEDs datasheet for best ratings but we like to use 270 ohm resistors. This banned the accepted to ~20mA, able-bodied aural a lot of LEDs and microcontroller ratings.
Step 2: Testing
Before we affix our RGB LED to our Arduino it's a acceptable abstraction to accord it a test.
Consult your RGB LEDs datasheet for its pin-out or beneath are the two a lot of accepted RGB LED anatomy factors and pin-outs.
Wire up the Analysis Schematic (below)
Plug the RGB LED into your breadboard
Connect a accepted attached resistor to anniversary of the three cathodes
Connect the accepted anode to 5V (5 volts)
Test anniversary blush by abutting its accepted attached resistor to arena (GND)
Experiment with colour bond a little by powering assorted elements at once
(a quick video of us testing an RGB LED)
Step 3: Archetype Circuit
Time to move on to authoritative your RGB LEDs with an Arduino.
For the archetype cipher to chase you'll charge three RGB LEDs and 9 accepted attached resistors (avaliable for acquirement in the UK from oomlout.co.uk )
Wire up the ambit below. 
There are two means to do this. For the added avant-garde argue the schematic below.
Or for the beneath avant-garde you can download a breadboard blueprint area (the pdf below). Print this out and lay it over your breadboard for acceptable basic placement.
Step 4: Agenda Arduino Code
It is accessible to ascendancy an RGB LED digitally. This requires 3 agenda pins for anniversary LED and allows for 7 colours to be displayed (Red, Green, Blue, Yellow, Cyan, Magenta, White).
But don't yield our chat for it download the cipher beneath and get playing. To do this simply...
Copy the cipher beneath and adhesive it into a an abandoned Arduino sketch.
Compile and upload the account to your Arduino board.
Enjoy as your three LEDs ablaze up Red, Green, and Blue.
If you go to the loop() area of the cipher beneath archetype 1 you can see area you change the colors. Try a few added variations
To see how we ascendancy anniversary LED attending at the setColor() function.
Next animadversion out (add //) to the three curve of archetype 1.
Un-comment (delete //) from in foreground of every band in the Archetype 2 area of the loop() code
Upload this to your lath and watch as your three LEDs change colour randomly.
Play about with the cipher to see how it works and accomplish your own fun blush functions.
Step 5: Analog Arduino Code
Now assimilate the fun stuff, authoritative an RGB LED application the Arduinos PWM (pulse amplitude modulation) pins. This lets you actualize about any colour your affection desires, and bigger than that achromatize amid colours. 
To do this anniversary LED requires 3 PWM pins. As the Arduino has alone 6 PWM pins alone two RGB LEDs can be controlled this way at a time. 
In agreement of the cipher we will use the analogWrite(pin, value) function, for added data appointment the cipher advertence on Arduino.cc )
To get arena with the your LEDs in an Analog address simply...
Copy and adhesive the cipher beneath into an abandoned Arduino sketch
Compile and upload the account to your Arduino board
Example one will alpha by axis the LED amethyst (you can again play about with the colour to change it to added presets, or ascertain your own)
Next animadversion out the Archetype 1 band (add //)
Un-Comment Archetype 2 (delete the //)
Compile and upload the archetype to your board.
Now watch as your LED turns a blanched blooming colour, change the numbers in the tempColor[] arrangement to change the displayed colour
Comment out Archetype 2 (add //)
Uncomment Archetype 3 (delete the //)
Compile and upload the affairs to your board
Watch as the LED fades from Red to Blooming To Blue. To see how this is accompished attending to the fadeToColor() function
Next get coding and authoritative your own fun colour alteration programmes
Step 6: Finished
By this point you've baffled authoritative an RGB LED led lights all that's larboard is advancing up with abundant account on how to use it. 
We accept endless of affairs for them about oomlout HQ and we'd adulation too apprehend about what you get up to. Please leave a coment beneath or forward us an e-mail to info@shgoodsun.com with any details.