Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
1,338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. // AtmoduinoV2 by NevCairiel, based on RickDB Atmoduino V1
  2.  
  3. #include <FastLED.h>
  4.  
  5. // Set the number of leds in the strip.
  6. #define NUM_LEDS 27
  7.  
  8. // type of the LED controller
  9. #define LED_TYPE WS2811
  10.  
  11. // data and clock pins
  12. #define DATA_PIN 11
  13.  
  14.  
  15. CRGB leds[NUM_LEDS];
  16.  
  17. void setup(){
  18.   Serial.begin(115200);
  19.   FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
  20.   clearLeds();
  21. }
  22.  
  23. int readByte(){
  24.   while (Serial.available() == 0){ /* wait for data */ }
  25.   return Serial.read();
  26. }
  27.  
  28. void clearLeds(){
  29.   for(int dot = 0; dot < NUM_LEDS; dot++){
  30.     leds[dot] = CRGB::Black;
  31.   };
  32.   FastLED.show();
  33. }
  34.  
  35. void loop() {
  36.   if(readByte() == 0xD7){
  37.     if(readByte() == 0xEE){
  38.       if(readByte() == 0x23){
  39.         int channels = readByte() + 1;
  40.         for(int dot = 0; dot < channels; dot++){
  41.           leds[dot].g = readByte();
  42.           leds[dot].b = readByte();
  43.           leds[dot].r = readByte();
  44.         }
  45.         FastLED.show();
  46.       }
  47.     }
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement