-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpov_ws2811.ino
79 lines (72 loc) · 1.71 KB
/
pov_ws2811.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <Adafruit_NeoPixel.h>
#define PIN A3
#define NUM_LEDS 16
// We use these macros because binary constants arent always supported. ugh.
#define HEX__(n) 0x##n##UL
#define B8__(x) ((x&0x0000000FLU)?1:0) +((x&0x000000F0LU)?2:0) +((x&0x00000F00LU)?4:0) +((x&0x0000F000LU)?8:0) +((x&0x000F0000LU)?16:0) +((x&0x00F00000LU)?32:0) +((x&0x0F000000LU)?64:0) +((x&0xF0000000LU)?128:0)
#define B8(d) ((unsigned char)B8__(HEX__(d)))
const static int image[] = { B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000),
B8(01000100),
B8(01010100),
B8(01111100),
B8(00000000),
B8(01000100),
B8(01000100),
B8(00111000),
B8(00000000),
B8(01110000),
B8(00011000),
B8(00010100),
B8(00010100),
B8(00011000),
B8(01110000),
B8(00000000),
B8(01000100),
B8(01010100),
B8(01111100),
B8(00000000),
B8(00011100),
B8(00010100),
B8(01111100),
B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000),
B8(00000000)};
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
int num_columns = sizeof(image);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
for (int c = 0; c < num_columns; c++) {
showColumn(c);
delay(5);
}
for (int c = num_columns - 1; c > -1; c--) {
showColumn(c);
delay(5);
}
}
void showColumn(int c) {
for (int i=0; i < 8; i++) {
if (image[c] & (0x1 << i)) {
strip.setPixelColor(2*(7-i), strip.Color(128,0,128));
strip.setPixelColor(2*(7-i)+1, strip.Color(128,0,128));
}
else {
strip.setPixelColor(2*(7-i), strip.Color(0,0,0));
strip.setPixelColor(2*(7-i)+1, strip.Color(0,0,0));
}
}
strip.show();
}