LEDControl/LED_Panel_arduino/LED_Panel_arduino.ino
2021-03-14 12:18:00 +01:00

47 lines
852 B
C++

#include <PololuLedStrip.h>
#define PIN 3
PololuLedStrip<PIN> leds;
#define LED_COUNT 512
#define BAUD 1000000
rgb_color colors[LED_COUNT];
#define BRIGHTNESS 10
void setup() {
PololuLedStripBase::interruptFriendly = true;
Serial.begin(BAUD);
Serial.setTimeout(500);
}
// main program
void loop() {
byte buf[1];
unsigned int c=0;
do{
c++;
if(Serial.readBytes(buf, 1) == 0) {
for (uint16_t i = 0; i < LED_COUNT; i++){
colors[i] = rgb_color(0, 0, 0);
}
leds.write(colors, LED_COUNT);
}
}while(buf[0] != 255);
if(c>1){
Serial.print("Invalid Data Bytes: ");
Serial.println(c);
}
for (uint16_t i = 0; i < LED_COUNT; i++)
{
char col[3];
Serial.readBytes(col, 3);
colors[i] = rgb_color(col[0], col[1], col[2]);
}
leds.write(colors, LED_COUNT);
}