jled icon indicating copy to clipboard operation
jled copied to clipboard

LowActive() causes weird Fade behaviour

Open RossAWaddell opened this issue 7 months ago • 5 comments

I need to connect the -ve pin of LEDs to the Arduino as I'm using a ULN2803A transistor to power 10 5mm LEDs. As this is the opposite of the usual single LED connection I'm using the LowActive() method to invert the fade, but it does a weird blip at the beginning which I don't see when connecting the +ve LED lead to the Arduino pin.

Any idea what's happening here? Ideally I'd like a smooth fade from off to the max brightness value.

+ve LED Lead Connected to Arduino Pin

#include <jled.h>

#define AMBER_LED_PIN 3
#define AMBER_LED_FADE_UP_TIME 4000// Time to power up (power first turned on)
#define PULSE_TIME 1200            // Fade down/up pulse time
#define MAX_BRIGHT_AMBER_LEDS 220
#define MIN_BRIGHT_AMBER_LEDS 110

JLed leds[] = {
JLed(AMBER_LED_PIN).FadeOn(AMBER_LED_FADE_UP_TIME).MaxBrightness(MAX_BRIGHT_AMBER_LEDS).DelayAfter(250),
    JLed(AMBER_LED_PIN).Fade(MAX_BRIGHT_AMBER_LEDS, MIN_BRIGHT_AMBER_LEDS, PULSE_TIME/2),
    JLed(AMBER_LED_PIN).Breathe(PULSE_TIME).MaxBrightness(MAX_BRIGHT_AMBER_LEDS)
      .MinBrightness(MIN_BRIGHT_AMBER_LEDS).DelayAfter(250).Forever()
};

JLedSequence amberLEDseq(JLedSequence::eMode::SEQUENCE, leds);

void setup() { }

void loop() {
    amberLEDseq.Update();
}

YouTube video

-ve LED Lead Connected to Arduino Pin w/ LowActive()

#include <jled.h>

#define AMBER_LED_PIN 3
#define AMBER_LED_FADE_UP_TIME 4000// Time to power up (power first turned on)
#define PULSE_TIME 1200            // Fade down/up pulse time
#define MAX_BRIGHT_AMBER_LEDS 220
#define MIN_BRIGHT_AMBER_LEDS 110

JLed leds[] = {
JLed(AMBER_LED_PIN).LowActive().FadeOn(AMBER_LED_FADE_UP_TIME).MaxBrightness(MAX_BRIGHT_AMBER_LEDS).DelayAfter(250),
    JLed(AMBER_LED_PIN).LowActive().Fade(MAX_BRIGHT_AMBER_LEDS, MIN_BRIGHT_AMBER_LEDS, PULSE_TIME/2),
    JLed(AMBER_LED_PIN).LowActive().Breathe(PULSE_TIME).MaxBrightness(MAX_BRIGHT_AMBER_LEDS)
      .MinBrightness(MIN_BRIGHT_AMBER_LEDS).DelayAfter(250).Forever()
};

JLedSequence amberLEDseq(JLedSequence::eMode::SEQUENCE, leds);

void setup() { }

void loop() {
    amberLEDseq.Update();
}

YouTube video

RossAWaddell avatar Jul 24 '24 19:07 RossAWaddell