-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e4a9d1
commit 45f3dbe
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// JLed fade from-to example. Example randomly fades to a new level with | ||
// and duration, choosing random values. | ||
// Copyright 2022 by Jan Delgado. All rights reserved. | ||
// https://github.com/jandelgado/jled | ||
#include <jled.h> | ||
|
||
auto led = JLed(5).On(1); // start with LED turned on | ||
|
||
void setup() {} | ||
|
||
void loop() { | ||
static uint8_t last_to = 255; | ||
|
||
if (!led.Update()) { | ||
// when effect is done (Update() returns false), | ||
// reconfigure fade effect using random values | ||
auto new_from = last_to; | ||
auto new_to = jled::rand8(); | ||
auto duration = 250 + jled::rand8() * 4; | ||
last_to = new_to; | ||
led.Fade(new_from, new_to, duration).Repeat(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters