Plug And Blink

This commit is contained in:
kekskurse 2019-07-10 19:07:12 +00:00
commit da4ad57a96

89
plugAndBlinK.ino Normal file
View file

@ -0,0 +1,89 @@
#define FADESPEED 5 // make this higher to slow down
#define REDPIN1 5
#define GREENPIN1 4
#define BLUEPIN1 16
#define REDPIN2 12
#define GREENPIN2 14
#define BLUEPIN2 13
void setup() {
pinMode(REDPIN1, OUTPUT);
pinMode(GREENPIN1, OUTPUT);
pinMode(BLUEPIN1, OUTPUT);
pinMode(REDPIN2, OUTPUT);
pinMode(GREENPIN2, OUTPUT);
pinMode(BLUEPIN2, OUTPUT);
analogWrite(BLUEPIN1, 0);
analogWrite(BLUEPIN2, 0);
analogWrite(REDPIN1, 255);
analogWrite(REDPIN2, 255);
analogWrite(GREENPIN1, 0);
analogWrite(GREENPIN2, 0);
}
void loop() {
analogWrite(BLUEPIN1, 0);
analogWrite(BLUEPIN2, 0);
analogWrite(REDPIN1, 255);
analogWrite(REDPIN2, 255);
analogWrite(GREENPIN1, 0);
analogWrite(GREENPIN2, 0);
delay(1000);
analogWrite(BLUEPIN1, 0);
analogWrite(BLUEPIN2, 0);
analogWrite(REDPIN1, 0);
analogWrite(REDPIN2, 0);
analogWrite(GREENPIN1, 255);
analogWrite(GREENPIN2, 255);
delay(1000);
analogWrite(BLUEPIN1, 255);
analogWrite(BLUEPIN2, 255);
analogWrite(REDPIN1, 0);
analogWrite(REDPIN2, 0);
analogWrite(GREENPIN1, 0);
analogWrite(GREENPIN2, 0);
delay(1000);
}
void loop2() {
int r, g, b;
// fade from blue to violet
for (r = 0; r < 256; r++) {
analogWrite(REDPIN1, r);
analogWrite(REDPIN2, r);
delay(FADESPEED);
}
// fade from violet to red
for (b = 255; b > 0; b--) {
analogWrite(BLUEPIN1, b);
analogWrite(BLUEPIN2, b);
delay(FADESPEED);
}
// fade from red to yellow
for (g = 0; g < 256; g++) {
analogWrite(GREENPIN1, g);
analogWrite(GREENPIN2, g);
delay(FADESPEED);
}
// fade from yellow to green
for (r = 255; r > 0; r--) {
analogWrite(REDPIN1, r);
analogWrite(REDPIN2, r);
delay(FADESPEED);
}
// fade from green to teal
for (b = 0; b < 256; b++) {
analogWrite(BLUEPIN1, b);
analogWrite(BLUEPIN2, b);
delay(FADESPEED);
}
// fade from teal to blue
for (g = 255; g > 0; g--) {
analogWrite(GREENPIN1, g);
analogWrite(GREENPIN2, g);
delay(FADESPEED);
}
}