Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define DATA_PIN 6
- //#define CLK_PIN 4
- #define LED_TYPE WS2811
- #define COLOR_ORDER GRB
- #define NUM_LEDS 270
- CRGB leds[NUM_LEDS];
- #define FRAMES_PER_SECOND 120
- byte serialIn;
- void setup() {
- delay(100);
- // put your setup code here, to run once:
- FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- FastLED.setBrightness(255);
- Serial.begin(115200);
- }
- int serialPos = 0;
- long lastMessage;
- byte inByte[4];
- void loop() {
- // put your main code here, to run repeatedly:
- for (int i = 0; i <= 90; i++) {
- leds[i].setRGB(inByte[0],0,0);
- }
- for (int i = 90; i <= 180; i++) {
- leds[i].setRGB(0,inByte[1],0);
- }
- for (int i = 180; i <= 270; i++) {
- leds[i].setRGB(0,0,inByte[2]);
- }
- FastLED.show();
- //FastLED.delay(1000/FRAMES_PER_SECOND);
- if (Serial.available() > 0) {
- if (millis() - lastMessage > 20) { // New message start
- serialPos = 0;
- }
- inByte[serialPos] = Serial.read();
- serialPos ++;
- lastMessage = millis();
- if (serialPos > 3) {
- serialPos = 3;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement