Hackster is hosting Impact Spotlights: Industrial Automation. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Industrial Automation. Stream on Thursday!
Khaled Md Saifullah
Published © MIT

Arduino Basic Project-#4

This project will discuss about the RGB LED.

BeginnerFull instructions provided30 minutes548
Arduino Basic Project-#4

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×3
Jumper wires (generic)
Jumper wires (generic)
×4
RGB Diffused Common Anode
RGB Diffused Common Anode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Fritzing

Story

Read more

Custom parts and enclosures

Arduino-Basic-Project-#4-fritzing-file

Schematics

Arduino-Basic-Project-#4-circuit-diagram(Common Cathode)

Arduino-Basic-Project-#4-circuit-diagram(Common Anode)

Code

Arduino-Basic-Project-#4 - Code

Arduino
//Date: 16/11/21
//Name: Khaled Md. Saifullah
//KastTech
//Dhaka,Bangladesh

int green = 8;
int blue = 9;
int red = 11;

void setup() {
  pinMode(red,OUTPUT);
  pinMode(green,OUTPUT);
  pinMode(blue,OUTPUT);

}

void loop() {
  //Red color light up
  digitalWrite(red,HIGH);
  digitalWrite(green,LOW);
  digitalWrite(blue,LOW);
  delay(1000);

  //Green color light up
  digitalWrite(red,LOW);
  digitalWrite(green,HIGH);
  digitalWrite(blue,LOW);
  delay(1000);

  //Blue color light up
  digitalWrite(red,LOW);
  digitalWrite(green,LOW);
  digitalWrite(blue,HIGH);
  delay(1000);
}

Arduino-Basic-Project-#4-code-2

Arduino
//Date: 18/11/21
//Name: Khaled Md. Saifullah
//KastTech
//Dhaka,Bangladesh

// RGB light using anolog value
int red= 11;
int blue = 9;
int green = 8;

void setup() {
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
}
void loop() {
  rgbColor(255, 0, 0); // Red
  delay(1000);
  rgbColor(0, 255, 0); // Green
  delay(1000);
  rgbColor(0, 0, 255); // Blue
  delay(1000);
  rgbColor(255, 255, 125); // Raspberry
  delay(1000);
  rgbColor(255,105,180); // Pink
  delay(1000);
  rgbColor(0, 255, 255); // Cyan
  delay(1000);
  rgbColor(255, 0, 255); // Magenta
  delay(1000);
  rgbColor(255, 255, 0); // Yellow
  delay(1000);
  rgbColor(255, 255, 255); // White
  delay(1000);
}
void rgbColor(int redValue, int greenValue, int blueValue)
 {
  analogWrite(red, redValue);
  analogWrite(green, greenValue);
  analogWrite(blue, blueValue);
}

Credits

Khaled Md Saifullah
18 projects • 44 followers
🦸Tech Enthusiast 👨🏾‍💻Programmer 📳IoT Specialist
Contact

Comments

Please log in or sign up to comment.