Advertisement
Guest User

led

a guest
Jan 10th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. #define NUM_LEDS 50
  2. #define DATA_PIN 6
  3.  
  4. //Fire
  5. #define BRIGHTNESS  200
  6. #define FRAMES_PER_SECOND 60
  7. #define COOLING  55
  8. #define SPARKING 120
  9.  
  10. CRGB leds[NUM_LEDS];
  11. int val;
  12.  
  13. //Fire
  14. bool gReverseDirection = false;
  15.  
  16. bool isStrobeWhiteOn = false;
  17. bool isFireOn = false;
  18.  
  19.  
  20. //-----------------------------------Setup-----------------------------------
  21.  
  22. void setup()
  23. {
  24.   Serial.begin(115200); // set serial speed
  25.   FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
  26.  
  27.   FastLED.setBrightness( BRIGHTNESS );
  28. }
  29.  
  30.  
  31. //-------------------------------------Loop-------------------------------------
  32.  
  33. void loop()
  34. {
  35.   if (Serial.available() == 0);
  36.   val = Serial.parseInt(); // deduct ascii value of '0' to find numeric value of sent number
  37.   {
  38.     if (val ==  1 )
  39.     {
  40.       fill_solid( leds, NUM_LEDS, CRGB::Red);
  41.       FastLED.show();
  42.     }
  43.     /////////
  44.     if (val == 2)
  45.     {
  46.       fill_solid( leds, NUM_LEDS, CRGB::Yellow);
  47.       FastLED.show();
  48.     }
  49.     /////////
  50.     {
  51.       if (val == 3 )
  52.         fill_solid( leds, NUM_LEDS, CRGB::Green);
  53.       FastLED.show();
  54.     }
  55.     if (val == 4 )
  56.     {
  57.       fill_solid( leds, NUM_LEDS, CRGB::Orange);
  58.       FastLED.show();
  59.     }
  60.     /////////
  61.     if (val == 5 )
  62.     {
  63.       fill_solid( leds, NUM_LEDS, CRGB::Purple);
  64.       FastLED.show();
  65.     }
  66.     /////////
  67.  
  68.     if (val == 6 )
  69.     {
  70.       fill_solid( leds, NUM_LEDS, CRGB::Blue);
  71.       FastLED.show();
  72.     }
  73.     /////////
  74.     if (val == 7 )
  75.     {
  76.       fill_solid( leds, NUM_LEDS, CRGB::Cyan);
  77.       FastLED.show();
  78.     }
  79.     /////////
  80.     if (val == 8 )
  81.     {
  82.       isStrobeWhiteOn = true;
  83.     }
  84.     /////////
  85.     if (val == 9 )
  86.     {
  87.       isFireOn = true;
  88.     }
  89.  
  90.  
  91.     Serial.println(val);
  92.  
  93.   }
  94.  
  95.   if (isStrobeWhiteOn)
  96.   {
  97.     StrobeWhite();
  98.   }
  99.  
  100.   if (isFireOn)
  101.   {
  102.     Fire2012();
  103.     FastLED.show(); // display this frame
  104.   }
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement