Advertisement
atuline

Triggered 8 bit breathing.

May 12th, 2020
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /* Triggered breathing
  2. *
  3. * By: Andrew Tuline
  4. *
  5. * Date: May, 2020
  6. *
  7. */
  8.  
  9. #include <FastLED.h>
  10.  
  11. #define LED_PIN 12
  12. #define NUM_LEDS 40
  13. #define COLOR_ORDER GRB
  14. #define LED_TYPE WS2812B
  15. #define MAX_BRIGHTNESS 255
  16.  
  17. struct CRGB leds[NUM_LEDS];
  18.  
  19. void setup() {
  20. Serial.begin(115200);
  21. LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  22. FastLED.setBrightness(MAX_BRIGHTNESS);
  23. FastLED.clear();
  24. }
  25.  
  26.  
  27.  
  28. void loop() {
  29.  
  30. EVERY_N_MILLIS(3000) {
  31. triggered(1);
  32. }
  33.  
  34. EVERY_N_MILLIS(10) {
  35. triggered(0);
  36. }
  37.  
  38. FastLED.show();
  39. } // loop()
  40.  
  41.  
  42.  
  43. void triggered(uint8_t trigger) {
  44.  
  45. static uint16_t counte = 256; // High count.
  46.  
  47. if (trigger) {counte=0;}
  48. if (counte < 256) {
  49. uint8_t breathing = cubicwave8(counte++);
  50. fill_solid(leds, NUM_LEDS, CHSV(40, 250, breathing));
  51. }
  52. } // triggered()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement