Arduino RGB Color Using LED module KY-016

thumbnail

Arduino example produces a scope of hues by blending red, green and blue. The measure of every primary color is balanced.

Hardware Required

  • Arduino UNO Board
  • 1 RGB LED module KY-016
  • Three 330ohm resistors
  • Breadboard
  • Jumper Wires

Circuit Diagram

Connect RGB ends of LED module KY-016 to 330ohm resistors. Then connect other ends of resistors with UNO Board using jumper wires (Blue -> Pin 9, Red->Pin 10, Green->Pin 11). Connect GND Leg of LED module KY-016 to GND of UNO Board.

Follow the below diagram:

Generated Using fritzing

Program

Open your Arduino IDE and paste the below code and compile the program then upload code to UNO Board. Make sure that you have connected your computer to the UNO Board. Once uploaded the code LED starts generating RGB combination colors.

const int blue = 9;//set blue to pin 9
const int red = 10;//set red to pin 10
const int green = 11;//set green to pin 11

void setup() {
pinMode(blue, OUTPUT);//set blue as an output
pinMode(red, OUTPUT);//set red as an output
pinMode(green, OUTPUT);//set green as an output
}

void loop() {
  
  digitalWrite(blue,HIGH);//color sequence for cycling through blue, red, green. One at a time.
  delay(1000);
  digitalWrite(blue,LOW);
  delay(1000);
  digitalWrite(red,HIGH);
  delay(1000);
  digitalWrite(red, LOW);
  delay(1000);
  digitalWrite(green, HIGH);
  delay(1000);
  digitalWrite(green, LOW);
  delay(1000);

  digitalWrite(blue, HIGH);//color sequence for purple
  digitalWrite(red, HIGH);
  digitalWrite(green, LOW);
  delay(1000);

  digitalWrite(blue, HIGH);//color sequence for turquoise
  digitalWrite(green, HIGH);
  digitalWrite(red, LOW);
  delay(1000);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

3 + 14 =

Back To Top