chemdoc77

New ring functions for garage detection unit

Nov 8th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. //Demo for new ring functions for garage detection unit by Chemdoc77
  2.  
  3. #include "FastLED.h"
  4. #define NUM_LEDS 24
  5.  
  6. #define Data_Pin 6
  7. #define chipset NEOPIXEL
  8. CRGB leds[NUM_LEDS];
  9.  
  10. void setup() {
  11. delay(2000); // power-up safety delay
  12. FastLED.addLeds<chipset, Data_Pin>(leds, NUM_LEDS);
  13. FastLED.setBrightness(60);
  14. FastLED.setMaxPowerInVoltsAndMilliamps(5,450);
  15. set_max_power_indicator_LED(13);
  16. }
  17.  
  18. //Predeclaration of functions
  19. void cd77_fill_part_ring(uint8_t numbertofill, CRGB color, uint8_t wait);
  20. void cd77_fill_ring(CRGB color, uint8_t wait);
  21.  
  22. void loop() {
  23.  
  24. cd77_fill_ring(CRGB::Green, 2000);
  25. FastLED.delay(1000);
  26. cd77_fill_part_ring(4, CRGB::Yellow, 200);
  27. FastLED.delay(500);
  28. cd77_fill_part_ring(8, CRGB::Yellow, 200);
  29. FastLED.delay(500);
  30. cd77_fill_part_ring(12, CRGB::Yellow,200);
  31. FastLED.delay(500);
  32. cd77_fill_ring(CRGB::Red, 5000);
  33. }
  34.  
  35. //======================================
  36.  
  37.  
  38. void cd77_fill_part_ring(uint8_t numbertofill, CRGB color, int wait){ //Note: numbertofil must never be larger than NUM_LEDS/2
  39. for (uint8_t i = 1; i <numbertofill; i++){
  40. leds[(NUM_LEDS/2)-i ] = color;
  41. leds[(NUM_LEDS/2)+i ] = color;
  42. FastLED.show();
  43. FastLED.delay(wait);
  44. }
  45. FastLED.delay(wait*2);
  46. fill_solid( leds, NUM_LEDS, CRGB::Black);
  47. FastLED.show();
  48. }
  49.  
  50. //==========================
  51. void cd77_fill_ring(CRGB color, int wait){
  52.  
  53. fill_solid(leds, NUM_LEDS, color);
  54. FastLED.show();
  55. FastLED.delay(wait);
  56. fill_solid( leds, NUM_LEDS, CRGB::Black);
  57. FastLED.show();
  58. }
Add Comment
Please, Sign In to add comment