commit da4ad57a9649071a5eede941287edd64db309678 Author: kekskurse Date: Wed Jul 10 19:07:12 2019 +0000 Plug And Blink diff --git a/plugAndBlinK.ino b/plugAndBlinK.ino new file mode 100644 index 0000000..0232796 --- /dev/null +++ b/plugAndBlinK.ino @@ -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); + } +}