3 Color RGB LED’s allow you to use a single LED to show multiple colors.
Functional Parts in the Project:
- Arduino Uno – https://store.arduino.cc/usa/arduino-uno-rev3
- 560 Piece Jumper Wire Kit – https://amzn.to/2MsCLjL
- 220 Ohm Resistors – https://amzn.to/2RiiMD9
- Breadboard Kit – https://amzn.to/2Xih5ei
#define redLed 8
#define greenLed 9
#define blueLed 10
void setup() {
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
}
void loop() {
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, LOW);
delay(1000);
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(blueLed, LOW);
delay(1000);
digitalWrite(redLed, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, HIGH);
delay(1000);
//Cyan
analogWrite(redLed, 0);
analogWrite(greenLed, 255);
analogWrite(blueLed, 255);
delay(1000);
//Magenta
analogWrite(redLed, 255);
analogWrite(greenLed, 0);
analogWrite(blueLed, 255);
delay(1000);
//Yellow
analogWrite(redLed, 255);
analogWrite(greenLed, 255);
analogWrite(blueLed, 0);
delay(1000);
//White
analogWrite(redLed, 255);
analogWrite(greenLed, 255);
analogWrite(blueLed, 255);
delay(1000);
}
Be the first to comment