Devices & Components
Arduino Uno Rev3
RGB Diffused Common Anode
RGB Diffused Common Cathode
Breadboard (generic)
Jumper wires (generic)
Resistor 220 ohm
Software & Tools
Arduino IDE
Project description
Code
Code
c_cpp
1// *Interfacing RGB LED with Arduino 2// * Author: Osama Ahmed 3 4//Defining variable and the GPIO pin on Arduino 5int redPin= 5; 6int greenPin = 6; 7int bluePin = 7; 8 9void setup() { 10 //Defining the pins as OUTPUT 11 pinMode(redPin, OUTPUT); 12 pinMode(greenPin, OUTPUT); 13 pinMode(bluePin, OUTPUT); 14} 15void loop() { 16 setColor(255, 0, 0); // Red Color 17 delay(1000); 18 setColor(0, 255, 0); // Green Color 19 delay(1000); 20 setColor(0, 0, 255); // Blue Color 21 delay(1000); 22 setColor(255, 255, 255); // White Color 23 delay(1000); 24 setColor(170, 0, 255); // Purple Color 25 delay(1000); 26 setColor(127, 127, 127); // Light Blue 27 delay(1000); 28} 29void setColor(int redValue, int greenValue, int blueValue) { 30 analogWrite(redPin, redValue); 31 analogWrite(greenPin, greenValue); 32 analogWrite(bluePin, blueValue); 33} 34
Downloadable files
Schematic for the project
Schematic for the project

Schematic for the project
Schematic for the project

Comments
Only logged in users can leave comments