#include <OctoWS2811.h>
const int ledsPerStrip = 89*8;
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
int microsec = 200000000 / leds.numPixels(); // change them all in 2 seconds
void setup() {
leds.begin();
leds.show();
// initialize serial:
Serial.begin(9600);
inputString.reserve(200);
}
#define RED 0xFF0000
#define GREEN 0x00FF00
#define BLUE 0x0000FF
#define YELLOW 0xFFFF00
#define PINK 0xFF1088
#define ORANGE 0xE05800
#define WHITE 0xFFFFFF
void loop() {
int inChar;
// uncomment for voltage controlled speed
// millisec = analogRead(A9) / 40;
// colorWipe(RED, microsec);
// colorWipe(GREEN, microsec);
// colorWipe(BLUE, microsec);
// colorWipe(YELLOW, microsec);
// colorWipe(PINK, microsec);
// colorWipe(ORANGE, microsec);
// colorWipe(WHITE, microsec);
if (stringComplete) {
//colorWipe(BLUE, microsec, inputString.toInt());
inputString="";
}
}
void colorWipe(int color, int wait, int LEDnum)
{
leds.setPixel(LEDnum+7*ledsPerStrip, color);
leds.show();
delayMicroseconds(wait);
Serial.print(LEDnum);
Serial.print('\n');
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
//inputString="";
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == ',') {
colorWipe(BLUE, microsec, inputString.toInt());
inputString="";
stringComplete = true;
}
if (inChar == 'o') {
for (int i = 0; i < ledsPerStrip; i++) {
leds.setPixel(i+7*ledsPerStrip, 0);
leds.show();
}
}
}
}