Mit RGB-LEDs besetzte Scheibe dimmt in regelmäßigen Abständen von Cyan nach Weiß. Externes 12V-Netzteil benötigt.
/*
* RGB_LED CLUSTER
* for RGB-LED CLUSTER REVOART with 4 pins
* (common cathode) and external power
* more info: http://tinyurl.com/6ofyhzj
*/
// choose pins for each of the LED's colors
int bluePin = 11;
int redPin = 10;
int greenPin = 9;
// define a boolean variable (true/false) default = false
boolean switchPosition;
int redTime, valR, valG, valB;
void setup() {
// declare the pinmode (INPUT/OUTPUT) of
// digital pins (in this case 11, 10, 9)
pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(redPin, OUTPUT);
}
void loop() {
// asks for the switchPosition (true/false) and counts from 0 to 255 and backwards
if (switchPosition == false) redTime++;
else redTime--;
if (redTime >= 255) switchPosition = true;
if (redTime <= 0) switchPosition = false;
analogWrite(redPin, redTime); // changes the value of one color continously
analogWrite(greenPin, 255);
analogWrite(bluePin, 255);
delay(10); // speed of colorchange
}
