Things used in this project

Hardware components:
A000066 iso both
Arduino UNO & Genuino UNO
×1
SparkFun Common Cathode RGB LED
×1
SparkFun Common Anode RGB LED
×1
Mfr 25fbf52 221r sml
Resistor 221 ohm
×3
11026 02
Jumper wires (generic)
×1
12002 04
Breadboard (generic)
×1
Software apps and online services:
Ide web
Arduino IDE

Schematics

Schematics for the project
Schematic is for Common Cathode. Put the common pin to 5V instead of GND for Common anode.
Rgb led schematic nxh560bdvq et208cfyxl

Code

Common Cathode LED codeC/C++
/***

    Made by - Techduino
    
    NOTE: New model RGB leds have green and blue leads interchanged. Please refer     to the datasheet of the correspoding led model from the seller's site.
    
    Use the Serial Monitor to enter the values for each color component out of 
    255.
    
***/

/***declaring RGB pins in PWM mode***/
int red = 11;
int green = 9;
int blue = 10;

/***brightness control variables***/
int redBrightness = 0;
int greenBrightness = 0;
int blueBrightness = 0;
  
  void setup() {
  
    Serial.begin(9600);         //initialising serial monitor
  
    /***Pin mode declaration***/
    pinMode(red, OUTPUT);
    pinMode(green, OUTPUT);
    pinMode(blue, OUTPUT);
    
  }
  
  void loop() {
    
    Serial.println("::Enter color brightness::");
    
    Serial.print("Red : ");         //for red
    while(Serial.available()==0){
    }
    redBrightness = Serial.parseInt();
    Serial.println(redBrightness);
    
    Serial.print("Green : ");         //for green
    while(Serial.available()==0){
    }
    greenBrightness = Serial.parseInt();
    Serial.println(greenBrightness);
  
    Serial.print("Blue : ");         //for blue
    while(Serial.available()==0){
    }
    blueBrightness = Serial.parseInt();
    Serial.println(blueBrightness);
    Serial.println("   ");
  
    /***sending variable voltages to RGB led***/
    analogWrite(red, redBrightness);
    analogWrite(green, greenBrightness);
    analogWrite(blue, blueBrightness);
    delay(3000);
    
    }
Common Anode LED CodeC/C++
/***

    Made by - Techduino
    
    NOTE: New model RGB leds have green and blue leads interchanged. Please refer     to the datasheet of the correspoding led model from the seller's site.
    
    Use the Serial Monitor to enter the values for each color component out of 
    255.
    
***/

/***declaring RGB pins in PWM mode***/
int red = 11;
int green = 9;
int blue = 10;

/***brightness control variables***/
int redBrightness = 0;
int greenBrightness = 0;
int blueBrightness = 0;
  
  void setup() {
  
    Serial.begin(9600);         //initialising serial monitor
  
    /***Pin mode declaration***/
    pinMode(red, OUTPUT);
    pinMode(green, OUTPUT);
    pinMode(blue, OUTPUT);
    
  }
  
  void loop() {
    
    Serial.println("::Enter color brightness::");
    
    Serial.print("Red : ");         //for red
    while(Serial.available()==0){
    }
    redBrightness = 255 - Serial.parseInt();
    Serial.println(redBrightness);
    
    Serial.print("Green : ");         //for green
    while(Serial.available()==0){
    }
    greenBrightness = 255 - Serial.parseInt();
    Serial.println(greenBrightness);
  
    Serial.print("Blue : ");         //for blue
    while(Serial.available()==0){
    }
    blueBrightness = 255 - Serial.parseInt();
    Serial.println(blueBrightness);
    Serial.println("   ");
  
    /***sending variable voltages to RGB led***/
    analogWrite(red, redBrightness);
    analogWrite(green, greenBrightness);
    analogWrite(blue, blueBrightness);
    delay(3000);
    
    }

Credits

2017 22 08 00 15 50 ija7bdjo2o
Techduino
5 projects • 54 followers
Pursuing B.Tech. in CSE from SRM Institute of Science and Technology. A tech enthusiast and Arduino lover! 'Techduino' is my pen name.
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog