Last active
November 5, 2022 19:10
-
-
Save wearethefoos/30f7940edfa47fc76cb926d57e440e8b to your computer and use it in GitHub Desktop.
Light Festival Demo Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const byte rgb_8_r = 13; | |
const byte rgb_8_b = 15; | |
const byte rgb_8_g = 2; | |
const byte rgb_7_r = 0; | |
const byte rgb_7_b = 4; | |
const byte rgb_7_g = 16; | |
const byte rgb_6_r = 17; | |
const byte rgb_6_b = 5; | |
const byte rgb_6_g = 18; | |
const byte rgb_5_r = 23; | |
const byte rgb_5_b = 19; | |
const byte rgb_5_g = 22; | |
const byte rgb_4_r = 12; | |
const byte rgb_4_b = 14; | |
const byte rgb_4_g = 27; | |
const byte rgb_3_r = 26; | |
const byte rgb_3_b = 25; | |
const byte rgb_3_g = 33; | |
const byte rgb_12_r = 32; | |
const byte rgb_12_b = 35; | |
const byte rgb_12_g = 34; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(rgb_8_r, OUTPUT); | |
pinMode(rgb_8_b, OUTPUT); | |
pinMode(rgb_8_g, OUTPUT); | |
pinMode(rgb_7_r, OUTPUT); | |
pinMode(rgb_7_b, OUTPUT); | |
pinMode(rgb_7_g, OUTPUT); | |
pinMode(rgb_6_r, OUTPUT); | |
pinMode(rgb_6_b, OUTPUT); | |
pinMode(rgb_6_g, OUTPUT); | |
pinMode(rgb_5_r, OUTPUT); | |
pinMode(rgb_5_b, OUTPUT); | |
pinMode(rgb_5_g, OUTPUT); | |
pinMode(rgb_4_r, OUTPUT); | |
pinMode(rgb_4_b, OUTPUT); | |
pinMode(rgb_4_g, OUTPUT); | |
pinMode(rgb_3_r, OUTPUT); | |
pinMode(rgb_3_b, OUTPUT); | |
pinMode(rgb_3_g, OUTPUT); | |
pinMode(rgb_12_r, OUTPUT); | |
pinMode(rgb_12_b, OUTPUT); | |
pinMode(rgb_12_g, OUTPUT); | |
} | |
const byte reds[] = {rgb_8_r, | |
rgb_7_r, | |
rgb_6_r, | |
rgb_5_r, | |
rgb_4_r, | |
rgb_3_r, | |
rgb_12_r}; | |
const byte greens[] = {rgb_8_g, | |
rgb_7_g, | |
rgb_6_g, | |
rgb_5_g, | |
rgb_4_g, | |
rgb_3_g, | |
rgb_12_g}; | |
const byte blues[] = {rgb_8_b, | |
rgb_7_b, | |
rgb_6_b, | |
rgb_5_b, | |
rgb_4_b, | |
rgb_3_b, | |
rgb_12_b}; | |
const int timer = 500; | |
void loop() { | |
on_all_all(); | |
flash_all(reds); | |
on_all_all(); | |
flash_all(greens); | |
on_all_all(); | |
flash_all(blues); | |
off_all_all(); | |
flash_all(reds); | |
off_all_all(); | |
flash_all(greens); | |
off_all_all(); | |
flash_all(blues); | |
} | |
void on_all_all() { | |
on_all(reds); | |
on_all(greens); | |
on_all(blues); | |
} | |
void off_all_all() { | |
off_all(reds); | |
off_all(greens); | |
off_all(blues); | |
} | |
void on_all(const byte leds[]) { | |
for (byte i = 0; i < 7; i++) { | |
digitalWrite(leds[i], LOW); | |
} | |
} | |
void off_all(const byte leds[]) { | |
for (byte i = 0; i < 7; i++) { | |
digitalWrite(leds[i], HIGH); | |
} | |
} | |
void flash_all(const byte leds[]) { | |
for (byte i = 0; i < 7; i++) { | |
digitalWrite(leds[i], LOW); | |
delay(timer); | |
digitalWrite(leds[i], HIGH); | |
delay(timer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment