Guest User

FastLED strobing effect

a guest
Sep 2nd, 2018
1,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. bool isOn = false;
  2. uint32_t lastStrobeMs = 0; // The previous light change time.
  3. uint8_t strobeMs = 50; // Strobing frequency
  4. CRGB strobeColor = CRGB::White;
  5.  
  6. void setup() {
  7.   // The usual FastLED setup stuff
  8. }
  9.  
  10. void loop() {
  11.   // Read from sensors etc. to change strobeMs and/or strobeColor values here.
  12.  
  13.   uint32_t ms = millis();
  14.   if (ms - lastStrobeMs >= strobeMs) {
  15.     fill_solid(leds, NUM_LEDS, isOn ? CRGB::Black : strobeColor);
  16.     isOn = !isOn;
  17.     lastStrobeMs = ms;
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment