├── .vscode └── settings.json ├── README.md └── arduino_led_mask └── arduino_led_mask.ino /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # arduino-led-mask 2 | 3 | ![schematics for Rave Mask](https://armaizadenwala.com/static/arduino_led_rave_mask_full-ef185b7919f984218fd87ee1919773f0.png) 4 | 5 | View the guide here: https://armaizadenwala.com/blog/how-to-create-a-led-rave-mask-using-arduino/ 6 | 7 | 8 | ## Author 9 | 10 | Armaiz Adenwala 11 | 12 | [Software Engineer Portfolio](https://armaizadenwala.com/) 13 | -------------------------------------------------------------------------------- /arduino_led_mask/arduino_led_mask.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN A5 4 | #define NUM_LEDS 161 5 | #define NUM_ROWS 7 6 | #define NUM_FIRST_ROW 26 7 | #define LED_TYPE WS2812B 8 | #define BRIGHTNESS 20 9 | 10 | CRGB leds[NUM_LEDS]; 11 | 12 | void setup() 13 | { 14 | FastLED.addLeds(leds, NUM_LEDS); 15 | FastLED.setMaxPowerInVoltsAndMilliamps(4.5, 500); 16 | FastLED.show(); 17 | } 18 | 19 | // Examples of designs you can loop through 20 | void loop() 21 | { 22 | uint_least8_t circlePattern[NUM_LEDS] = { 23 | 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 1, 1, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 24 | 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 2, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 25 | 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 26 | 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 27 | 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 3, 2, 1, 0,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 1, 0, 4, 3, 2, 1, 0, 46 | 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 47 | 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 48 | 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0 49 | }; 50 | 51 | uint_least8_t lineColors[5] = { 4, 4, 5, 5, 5 }; 52 | uint_least8_t line2Colors[6] = { 6, 6, 5, 5, 8, 8 }; 53 | uint_least8_t verticalColors[5] = { 9, 9, 10, 10, 10 }; 54 | uint_least8_t vertical2Colors[20] = { 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 2, 2, 2, 2, 2 }; 55 | uint_least8_t circleColors[5]= { 0, 0, 0, 1, 1}; 56 | uint_least8_t circleColors2[5] = { 2, 2, 2, 3, 3 }; 57 | 58 | pattern(circlePattern, circleColors, false, 1, 5); 59 | pattern(circlePattern, circleColors, false, 1, 5); 60 | 61 | pattern(circlePattern, circleColors2, true, 1, 5); 62 | pattern(circlePattern, circleColors2, true, 1, 5); 63 | 64 | pattern(linePattern, lineColors, false, 1, 5); 65 | pattern(linePattern, lineColors, false, 1, 5); 66 | 67 | // pattern(line2Pattern, line2Colors, false, 3, 6); 68 | // pattern(line2Pattern, line2Colors, false, 3, 6); 69 | 70 | pattern(verticalLinePattern, verticalColors, false, 1.5, 5); 71 | pattern(verticalLinePattern, verticalColors, false, 1.5, 5); 72 | 73 | pattern(linePattern, vertical2Colors, false, 1.5, 20); 74 | } 75 | 76 | void pattern(uint_least8_t pattern[NUM_LEDS], uint_least8_t rgbColors[5], bool reverse, float speed, uint_least8_t max) { 77 | uint_least8_t colors[11][3] = { 78 | {95, 0, 10}, 79 | {130, 170, 23}, 80 | {5, 100, 150}, 81 | {120, 35, 190}, 82 | {5, 160, 60}, 83 | {60, 35, 150}, 84 | {5, 100, 150}, 85 | {0, 30, 170}, 86 | {140, 165, 10}, 87 | {130, 130, 130}, 88 | {10, 100, 00} 89 | }; 90 | for (uint_least8_t x = 0; x < max; x++) { 91 | for (uint_least8_t z = 0; z < (4 * speed); z++) { 92 | for (uint_least8_t i = 0; i < NUM_LEDS; i++) { 93 | uint_least8_t colorA; 94 | uint_least8_t colorB; 95 | if (reverse) { 96 | colorB = (pattern[i] + (4 - x)) % max; 97 | colorA = (colorB + 1) % max; 98 | } else { 99 | colorA = (pattern[i] + x) % max; 100 | colorB = (colorA + 1) % max; 101 | } 102 | leds[i] = CRGB( 103 | getColorFade(colors[rgbColors[colorA]][0], colors[rgbColors[colorB]][0], z, (4 * speed), i), 104 | getColorFade(colors[rgbColors[colorA]][1], colors[rgbColors[colorB]][1], z, (4 * speed), i), 105 | getColorFade(colors[rgbColors[colorA]][2], colors[rgbColors[colorB]][2], z, (4 * speed), i) 106 | ); 107 | } 108 | FastLED.show(); 109 | FastLED.delay(1); 110 | } 111 | } 112 | } 113 | 114 | float getColorFade(uint_least8_t a, uint_least8_t b, uint_least8_t index, uint_least8_t range, uint_least8_t i) { 115 | if (a == b) 116 | { 117 | return a; 118 | } 119 | uint_least8_t dif = abs(a - b); 120 | float change = (float)dif / range * (index + 1); 121 | if (a > b) 122 | { 123 | return a - change; 124 | } 125 | return a + change; 126 | } 127 | --------------------------------------------------------------------------------