-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdc916_test0_partymode.ino
36 lines (27 loc) · 1.05 KB
/
dc916_test0_partymode.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
/*****
* Simple Party Mode test for the DC916 badge.
*
* Is a *slightly* modified version of Adafruit's DotStar library strand test example.
*/
#include <Adafruit_DotStar.h>
#include <SPI.h>
#define NUMPIXELS 4
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS);
void setup() {
strip.begin();
strip.show();
}
int head = 0, tail = -10; // Index of first 'on' and 'off' pixels
uint32_t color = 0xFF0000; // 'On' color (starts red)
void loop() {
strip.setPixelColor(head, color); // 'On' pixel at head
strip.setPixelColor(tail, 0); // 'Off' pixel at tail
strip.show(); // Refresh strip
delay(20); // Pause 20 milliseconds (~50 FPS)
if(++head >= NUMPIXELS) { // Increment head index. Off end of strip?
head = 0; // Yes, reset head index to start
if((color >>= 8) == 0) // Next color (R->G->B) ... past blue now?
color = 0xFF0000; // Yes, reset to red
}
if(++tail >= NUMPIXELS) tail = 0; // Increment, reset tail index
}