Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Triggered breathing
- *
- * By: Andrew Tuline
- *
- * Date: May, 2020
- *
- */
- #include <FastLED.h>
- #define LED_PIN 12
- #define NUM_LEDS 40
- #define COLOR_ORDER GRB
- #define LED_TYPE WS2812B
- #define MAX_BRIGHTNESS 255
- struct CRGB leds[NUM_LEDS];
- void setup() {
- Serial.begin(115200);
- LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- FastLED.setBrightness(MAX_BRIGHTNESS);
- FastLED.clear();
- }
- void loop() {
- EVERY_N_MILLIS(3000) {
- triggered(1);
- }
- EVERY_N_MILLIS(10) {
- triggered(0);
- }
- FastLED.show();
- } // loop()
- void triggered(uint8_t trigger) {
- static uint16_t counte = 256; // High count.
- if (trigger) {counte=0;}
- if (counte < 256) {
- uint8_t breathing = cubicwave8(counte++);
- fill_solid(leds, NUM_LEDS, CHSV(40, 250, breathing));
- }
- } // triggered()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement