LEDControl/LED_Panel_arduino_neopixel/LED_Panel_arduino_neopixel.ino

45 lines
751 B
Arduino
Raw Normal View History

2021-03-14 12:18:00 +01:00
#include <Adafruit_NeoPixel.h>
#define PIN 3
#define LED_COUNT 512
#define BAUD 1000000
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
Serial.begin(BAUD);
Serial.setTimeout(500);
}
// main program
void loop() {
byte buf[1];
unsigned int c=0;
while(Serial.read() != 255){
if(c > 100000){
for (uint16_t i = 0; i < LED_COUNT; i++){
strip.setPixelColor(i, strip.Color(0,0,0));
}
strip.show();
}
c++;
}
if(c>1){
}
for (uint16_t i = 0; i < LED_COUNT; i++)
{
char col[3];
Serial.readBytes(col, 3);
strip.setPixelColor(i, strip.Color(col[0], col[1], col[2]));
}
strip.show();
}