Manikant savadatti
Published © GPL3+

How to use RGB Led with Arduino to produce 16M colours

In this post you will learn how to work with RGB LED’s. This Post i'll show you how to connect a Common Cathode RGB LED to an Arduino.

BeginnerProtip18 minutes26,443
How to use RGB Led with Arduino to produce 16M colours

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Resistor 100 ohm
Resistor 100 ohm
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

Arduino Circuit connection for RGB led

Code

Arduino Code for RGB led

C/C++
int redPin=11;
int greenPin=10;
int bluePin=9;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(redPin,OUTPUT);
pinMode(greenPin,OUTPUT);
pinMode(bluePin,OUTPUT);
}
 
void loop() {

  // put your main code here, to run repeatedly:

//red
  analogWrite(redPin,255);
  analogWrite(greenPin,0);
  analogWrite(bluePin,0);
//green
  analogWrite(redPin,0);
  analogWrite(greenPin,255);
  analogWrite(bluePin,0);
//blue
  analogWrite(redPin,0);
  analogWrite(greenPin,0);
  analogWrite(bluePin,255);
//magenta
  analogWrite(redPin,255);
  analogWrite(greenPin,0);
  analogWrite(bluePin,255);
//yellow
  analogWrite(redPin,255);
  analogWrite(greenPin,255);
  analogWrite(bluePin,0);
//cyan
  analogWrite(redPin,0);
  analogWrite(greenPin,255);
  analogWrite(bluePin,255);
//white
  analogWrite(redPin,255);
  analogWrite(greenPin,255);
  analogWrite(bluePin,255);


}

Credits

Manikant savadatti
8 projects • 14 followers
I'm an Robotics Enthusiast and an Electronics and communication Engineering student studying in India .
Contact

Comments

Please log in or sign up to comment.