LEDControl/LED_Panel_arduino/LED_Panel_arduino.ino

48 lines
852 B
Arduino
Raw Normal View History

2021-02-24 14:50:18 +01:00
#include <PololuLedStrip.h>
#define PIN 3
PololuLedStrip<PIN> leds;
2021-03-14 12:18:00 +01:00
#define LED_COUNT 512
2021-02-24 14:50:18 +01:00
#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{
2021-03-14 12:18:00 +01:00
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);
2021-02-24 14:50:18 +01:00
}
}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);
}