int redPin= 11;
int greenPin = 10;
int bluePin = 9 ;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
setColor(255, 0, 0); // Red Color
delay(1000);
setColor(0, 255, 0); // Green Color
delay(1000);
setColor(0, 0, 255); // Blue Color
delay(1000);
setColor(255, 255, 255); // White Color
delay(1000);
setColor(170, 0, 255); // Purple Color
delay(1000);
setColor(255,255,0);
delay(1000);
setColor(128,0,128);
delay(1000);
setColor(64,224,208);
delay(1000);
setColor(0,128,128);
delay(1000);
setColor(128,0,0);
delay(1000);
setColor(0,0,128);
delay(1000);
}
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
}
Control rgb sensor led
Fun with colors and code
Comments