Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool isOn = false;
- uint32_t lastStrobeMs = 0; // The previous light change time.
- uint8_t strobeMs = 50; // Strobing frequency
- CRGB strobeColor = CRGB::White;
- void setup() {
- // The usual FastLED setup stuff
- }
- void loop() {
- // Read from sensors etc. to change strobeMs and/or strobeColor values here.
- uint32_t ms = millis();
- if (ms - lastStrobeMs >= strobeMs) {
- fill_solid(leds, NUM_LEDS, isOn ? CRGB::Black : strobeColor);
- isOn = !isOn;
- lastStrobeMs = ms;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment