-
Notifications
You must be signed in to change notification settings - Fork 0
/
LEDTesterBox.ino
63 lines (55 loc) · 1.23 KB
/
LEDTesterBox.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <Adafruit_NeoPixel.h>
#include "WS2812_Definitions.h"
// defines the test string
#define TEST_PIN 8
#define LED_COUNT 128
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, TEST_PIN, NEO_GRB + NEO_KHZ800);
//defines the power LED
#define POWER_PIN 4
#define POWER_COUNT 1
Adafruit_NeoPixel power = Adafruit_NeoPixel(POWER_COUNT, POWER_PIN, NEO_GRB + NEO_KHZ800);
void setup()
{
// put your setup code here, to run once:
power.begin();
leds.begin();
}
void loop()
{
// put your main code here, to run repeatedly:
//whenever its on, turn this light green
power.setPixelColor(0, GREEN);
power.show();
cascade (BLUE, TOP_DOWN, 10);
cascade (PURPLE, TOP_DOWN, 10);
}
void cascade(unsigned long color, byte direction, byte wait)
{
if (direction == TOP_DOWN)
{
for (int i = 0; i < LED_COUNT; i++)
{
clearLEDs(); // Turn off all LEDs
leds.setPixelColor(i, color); // Set just this one
leds.show();
delay(wait);
}
}
else
{
for (int i = LED_COUNT - 1; i >= 0; i--)
{
clearLEDs();
leds.setPixelColor(i, color);
leds.show();
delay(wait);
}
}
}
void clearLEDs()
{
for (int i = 0; i < LED_COUNT; i++)
{
leds.setPixelColor(i, 0);
}
}