Cpm Affiliation : the cpm advertising network

الاثنين، 3 يوليو 2017


Arduino Uno and Triple output RGB Led:

Triple output RGB Led


Features:

  • Forward Voltage (RGB): (2.0, 3.2, 3.2)V
  • Max Forward Current (RGB): (20, 20, 20)mA
  • Max Luminosity (RGB): (2800, 6500, 1200)mcd

Documents:


RGB Led


You can use either one 4 pin RGB LED or three single color LEDs per port. Be sure to remember that when
you use three single color LEDs you must use the common cathode (negative �-�) for each port. I hope this diagram
helps.

circuit pic circuit schematic


3 resistore


A standard RGB LED has a single anode for all the colors, and three cathodes (one for each color).


1- Controlling an RGB LED with an Arduino.

cuircuit


Hardware Required
1-arduino
1-330ohm resistor
1-common cathode or common anode rgb led
1-breadboard
5-jumper wires

The way an Arduino controls LED brightness is by the frequency at which it pulses electricity on the pin. So, with a standard LED, if you have it set to pulse at a frequency of 255 it will appear to be very bright. If you give it a pulse frequency of 30, it will appear to be very dim.

An RGB LED works in the opposite way, so 30 will be very bright and 255 will be off completely. This is because the RGB LED is actually lit when electricity isn�t being pulsed (and the cathode can reach ground). So, a higher frequency gives it less time being lit, and a lower frequency gives it more time being lit.






  1. int red = 0;            //integer for red brightness
  2. int blue = 0;           //integer for blue brightness
  3. int green = 0;          //integer for green brightness
  4. int count = 0;          //integer for step count
  5. void setup() {
  6. pinMode(10, OUTPUT);  //sets the analog pin 10 as output
  7. pinMode(11, OUTPUT);  //sets the analog pin 11 as output
  8. pinMode(12, OUTPUT);  //sets the analog pin 12 as output
  9. }
  10. void loop() {
  11. if (count == 0) {      //step 1 makes LED red
  12. red = 0;             //red can reach ground
  13. blue = 255;          //blue cannot reach ground
  14. green = 255;         //green cannot reach ground
  15. }
  16. if (count == 1) {      //step 2 makes LED blue
  17. red = 255;           //red cannot reach ground
  18. blue = 0;            //blue can reach ground
  19. green = 255;         //green cannot reach ground
  20. }
  21. if (count == 2) {      //step 3 makes LED green
  22. red = 255;           //red cannot reach ground
  23. blue = 255;          //blue cannot reach ground
  24. green = 0;           //green can reach ground
  25. }
  26. if (count == 3) {      //step 4 mixes colors (purple)
  27. red = 0;             //red can reach ground
  28. blue = 0;            //blue can reach ground
  29. green = 255;         //green cannot reach ground
  30. }
  31. analogWrite(12, blue);  //writes the blue value to pin 12
  32. analogWrite(11, green)//writes the green value to pin 11
  33. analogWrite(10, red);   //writes the red value to pin 10
  34. count = count + 1;      //increases count by 1
  35. if (count > 3) count = 0;  //resets count to 0 if it�s over 3
  36. delay(1000);            //pauses for 1 second on each color
  37. }


This program will make the LED red for a second, then blue, then green, then purple, and then it will repeat. Try changing the values in step four to get different color combinations. The result should be like this video (ignore the random talking in the backround�).

Controlling an RGB LED with an Arduino ( YouTube Video)