0% found this document useful (0 votes)
5 views

RGB Code

The document is an Arduino sketch that controls three individual LEDs (red, green, blue) and an RGB LED. It sets up the pins for each LED as outputs and then enters a loop where it cycles through turning each LED on and off in a sequence, creating different colors with the RGB LED. Each color change is accompanied by a one-second delay.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

RGB Code

The document is an Arduino sketch that controls three individual LEDs (red, green, blue) and an RGB LED. It sets up the pins for each LED as outputs and then enters a loop where it cycles through turning each LED on and off in a sequence, creating different colors with the RGB LED. Each color change is accompanied by a one-second delay.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#define redLed 13

#define greenLed 12

#define blueLed 11

#define rgbRed 8

#define rgbGreen 9

#define rgbBlue 10

void setup() {

// put your setup code here, to run once:

pinMode(redLed, OUTPUT);

pinMode(greenLed, OUTPUT);

pinMode(blueLed, OUTPUT);

pinMode(rgbRed, OUTPUT);

pinMode(rgbGreen, OUTPUT);

pinMode(rgbBlue, OUTPUT);

void loop() {

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

digitalWrite(redLed, HIGH); // Turn on the red LED


digitalWrite(greenLed, LOW);

digitalWrite(blueLed, LOW);

digitalWrite(rgbRed, HIGH); // Blue + Red = Magenta

digitalWrite(rgbGreen, LOW);

digitalWrite(rgbBlue, HIGH);

delay(1000);

digitalWrite(redLed, LOW); // Turn on the green LED

digitalWrite(greenLed, HIGH);

digitalWrite(blueLed, LOW);

digitalWrite(rgbRed, HIGH); // Red + Green = Yellow

digitalWrite(rgbGreen, HIGH);

digitalWrite(rgbBlue, LOW);

delay(1000);

digitalWrite(redLed, LOW); // Turn on the blue LED

digitalWrite(greenLed, LOW);

digitalWrite(blueLed, HIGH);

digitalWrite(rgbRed, LOW); // Green + Blue = Cyan

digitalWrite(rgbGreen, HIGH);

digitalWrite(rgbBlue, HIGH);

delay(1000);

You might also like