-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Startup Fade in Setup() #21
Comments
Hmmm. I'm not really sure. Your code looks right. A couple things to try: Perhaps to explicitly set it to off initially: amber_led = LEDFader(AMBER_LED_PIN);
amber_led.set_value(0);
amber_led.fade(MAX_BRIGHTNESS, FADE_UP_TIME); Alternatively, try setting the fade time from 7 seconds to something like 2 seconds. Let me know if either changes it. |
I simplified the code to just the LEDs I want to fade in:
#include <LEDFader.h> // Don't forget to include the LEDFader libraries folder
#include <Curve.h>
// Config for pulsing amber LEDs
// =============================
#define AMBER_LED_PIN 11 // Amber LEDs (5 in pentagon shape)
#define FADE_UP_TIME 5000 // Time to power up
#define PULSE_TIME 600 // Fade down/up pulse time
#define MAX_BRIGHTNESS 235 // Max brightness of LEDs
#define MIN_BRIGHTNESS 180 // Min brightness of LEDs to fade to (pulse)
#define DIR_UP 1
#define DIR_DOWN -1
LEDFader amber_led;
int direction = DIR_UP;
void setup() {
amber_led = LEDFader(AMBER_LED_PIN);
amber_led.set_curve(&Curve::exponential);
amber_led.set_value(0);
amber_led.fade(MAX_BRIGHTNESS, FADE_UP_TIME);
//amber_led.set_curve(&Curve::linear);
}
void loop() {
// Pulsing amber LEDs
// ==================
amber_led.update();
// LED no longer fading, switch direction
if (amber_led.is_fading() == false) {
// Fade down
if (direction == DIR_UP) {
amber_led.fade(MIN_BRIGHTNESS, PULSE_TIME);
direction = DIR_DOWN;
}
// Fade up
else {
amber_led.fade(MAX_BRIGHTNESS, PULSE_TIME);
direction = DIR_UP;
}
}
}
By adding the curve=exponential it looks better, but it's not exactly smooth. Here's a video: https://youtu.be/cxZGFXAEg3A <https://youtu.be/cxZGFXAEg3A>
… On Jun 27, 2017, at 6:21 PM, Jeremy Gillick ***@***.***> wrote:
Hmmm. I'm not really sure. Your code looks right. A couple things to try:
Perhaps to explicitly set it to off initially:
amber_led = LEDFader(AMBER_LED_PIN);
amber_led.set_value(0);
amber_led.fade(MAX_BRIGHTNESS, FADE_UP_TIME);
Alternatively, try setting the fade time from 7 seconds to something like 2 seconds.
Let me know if either changes it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#21 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AcVSZNFjNIXwDq00vtbSKeeGBuB_g00_ks5sIYBxgaJpZM4OFX2M>.
|
(apologies for re-opening this issue, but I'm trying to solve this again) I tried adding amber_led.set_value(0); as you suggested, but no change - the LED goes straight on before fading up/down. I tried the example sketch, singleLED, and same result (see video). I've got pin 3 of my Uno connected to the -ve lead of the LED, and then the +ve lead goes through a resistor to +5v. IMG_5755-2.mp4 |
First of all, thank you so much for this library! A fellow hobbyest pointed me to this code and with it I've been able to create the exact look I've been after for years, with only one small issue:
I want to fade up an LED in the void setup() loop over 2-3 seconds, but no matter how long I make the duration (it's set below to 7 seconds) it just sorta turns on - no real gradual fading. I'm using an Arduino Pro Mini board (5V, 16Mhz) and all 6 PWM pins.
Here's my code:
The text was updated successfully, but these errors were encountered: