/
LED_sine_simple_demo.ino
46 lines (37 loc) · 1.1 KB
/
LED_sine_simple_demo.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
#include "SPI.h"
#include "Zoa_WS2801.h"
#include "Sine_generator.h"
#include "MsTimer2.h"
int dataPin = 2; // Yellow wire on Adafruit Pixels
int clockPin = 3; // Green wire on Adafruit Pixels
int stripLen = 50;
// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
Zoa_WS2801 strip = Zoa_WS2801(stripLen, dataPin, clockPin);
Sine_generator sine_green = Sine_generator( 0, 255, 13/4, 0 );
Sine_generator sine_blue = Sine_generator( 0, 255, 7/4, 0 );
Sine_generator sine_red = Sine_generator( 0, 30, 5/4, 0 );
void setup()
{
Serial.begin(9600);
strip.begin();
// sets the update function to be called at a given interval (ms)
MsTimer2::set(40, &update_sine );
MsTimer2::start();
}
void loop()
{
/*
// This produces essentially the same result as the interrupt callback
// If you uncomment this, comment out the MsTimer2 initialization lines in setup.
for ( unsigned int i = 1; i >= 0; ++i )
{
update_sine();
delay(200);
}
*/
}
void update_sine()
{
strip.pushFront( sine_green.next_value(), sine_red.next_value(), sine_blue.next_value() );
strip.show();
}