Power Switch LED Fading Effect

Thread Starter

Grogaard Systems

Joined May 30, 2024
1
I have this non-latching metal power switch with an LED inside, to light up the "power symbol" on the switch.
I am currently looking after a circuit that can make this LED gently fade-in whenever power is connected to the circuit.
The switch uses a "standard" (or "normal") LED.
The spesifications of the switch states that the led has a supply voltage of 3v - 6v.
(All of the other information about the inside LED is lost, due to the site beeing unavailable.)

I whould greatly apreciate any efforts put into this to help me, and others who are experiencing the same.
Thank you for your time :)

- Lucas
 

Ya’akov

Joined Jan 27, 2019
9,277
Welcome to AAC.

You want to research PWM (Pulse Width Modulation). The best way to do this is with an 8-pin MCU like the ATTiny13A. One IC, and two or three passives with revisions in firmware rather than with a soldering iron. Or, you can get one of the many LED driver chips that support “breathing” for about 30 cents a piece.

Really this depends on the application—is it one off, industrial scale, ???
 

LowQCab

Joined Nov 6, 2012
4,356
This "cool-gimmick" sounds like way to much time and expense to be worthwhile.

The below Schematic will point you in the right direction.
You will need an ~8-Volt power source, and a big-fat Capacitor connected to the Wiper on the Pot.
The size of the Capacitor will determine the ramp-up time.
.
.
.
Alternative Dimming Circuit .png
 

Irving

Joined Jan 30, 2016
4,088
tend to agree, unless you already have an MCU doing other stuff, the amount of monkey business required to dim up the LED is not commensurate with the result.
I beg to differ, up n running in 20min

Code:
// up/down on pin 1 = PB0
#define UP_DOWN 0
// LED on pin 4 = PB2
#define LED 2

void setup(){
  pinMode(0, INPUT);
  pinMode(2,OUTPUT);
  delay(100);
}

int loopCount = 0;

void loop(){
  analogWrite(LED, 8 * loopCount);
  delay(32);
  loopCount += (digitalRead(UP_DOWN)  == 1) ? 1 : -1;
  loopCount = (loopCount > 32) ? 32 : (loopCount < 0) ? 0 : loopCount;
}
Edited for bugfix.
 
Last edited:

Jony130

Joined Feb 17, 2009
5,541
I beg to differ, up n running in 20min

Code:
// up/down on pin 1 = PB0
#define UP_DOWN 0
// LED on pin 4 = PB2
#define LED 2

void setup(){
  pinMode(0, INPUT);
  pinMode(2,OUTPUT);
  delay(100);
}

int loopCount = 0;

void loop(){
  digitalWrite(LED, 8 * loopCount);
  delay(32);
  loopCount += (digitalRead(UP_DOWN)  == 1) ? 1 : -1;
  loopCount = (loopCount > 32) ? 32 : (loopCount < 0) ? 0 : loopCount;
}
Can you explain to me how this code will gently fade-in the LED? Because I do not see it.
 

Wendy

Joined Mar 24, 2008
23,492
You want the fade before or after the switch is turned on or off? I am an analog type myself I'll see if I can draw something.
 

AnalogKid

Joined Aug 1, 2013
11,225
I beg to differ, up n running in 20min
Really? You went from never having touched a microcontroller in your life to writing error free code, and programming a device (with what, and where did it come from?), and wiring it to the LED in 20 minutes? I'm impressed. Please post the schematic.

ak
 

Irving

Joined Jan 30, 2016
4,088
Really? You went from never having touched a microcontroller in your life to writing error free code, and programming a device (with what, and where did it come from?), and wiring it to the LED in 20 minutes? I'm impressed. Please post the schematic.

ak
Of course not AK. It's the power of the internet - there's always someone out there who can help.

Now, if the TS really wants to learn how it's done, from scratch, or play with alternatives then good for him. We know nothing about his skill set.

I'm not saying it's the final solution, we don't know the environment or anything, could be a one off or a production requirement, voltages, etc.

Play with a dozen or so THT parts if you like, then try to squeeze them onto a board somewhere.

If this is, as I suspect a standard 12 or 16mm switch body with pins then a small pcb hung on the pins is the simple answer.

Schematic as per post #5 but with pin 1 connected to +out via a suitable high value resistor.

Can you explain to me how this code will gently fade-in the LED? Because I do not see it.
Thanks Jony for pointing out my deliberate mistake, now corrected & I hope you can see it now.
 

ElectricSpidey

Joined Dec 2, 2017
2,900
What is the power being switched?
IE: AC or DC, voltage?

How is the LED terminated, does it have a common connection with the switch.
Does the LED already have a resistor connected internally?

A nice fade up can be had using a capacitor some resistors and an Op-Amp in follower mode or even just a transistor.
 

AnalogKid

Joined Aug 1, 2013
11,225
Given the voltage rating for the LED, my guess is that the LED has a fixed resistor in series. Thus, a simple R-C circuit will work, but the extra R in series will reduce the peak LED brightness.

Same questions - Switched power voltage and current?

Power source for the LED fade circuit?

Photo of the switch pins?

ak
 

ElectricSpidey

Joined Dec 2, 2017
2,900
Basic brain-dead simple fade-up from power up.

Assumes 12 volts DC power.
Divider provides 6-volt output.
Assumes 20mA LED current @ 6 volts.
Rise time approx. 5 seconds.

Adjust component values as needed.
Op-Amp is any suitable model. (unity stable, current/wattage etc.)

1717346066272.png
 

Sensacell

Joined Jun 19, 2012
3,510
Basic brain-dead simple fade-up from power up.

Assumes 12 volts DC power.
Divider provides 6-volt output.
Assumes 20mA LED current @ 6 volts.
Rise time approx. 5 seconds.

Adjust component values as needed.
Op-Amp is any suitable model. (unity stable, current/wattage etc.)

View attachment 323726
I think the performance of this would disappoint visually.
The relationship between LED current and brightness would make it look like the LED comes on sharply, and just gets brighter, not very smooth.
This is why we use 12 bit PWM to get smooth dimming.
 

Irving

Joined Jan 30, 2016
4,088
I think the performance of this would disappoint visually.
The relationship between LED current and brightness would make it look like the LED comes on sharply, and just gets brighter, not very smooth.
This is why we use 12 bit PWM to get smooth dimming.
My point exactly...

Q. Best way to get smooth controlled brightness from a non-linear LED? A. PWM
Q. Best way to get controlled PWM? A. An MCU.
Q. what characteristics for MCU are needed? A. 1 input to sense power on/off; 1 output to drive LED. Low operating current. Low internal operating clock speed. Internal power on reset. 1 timer function. Low cost. Small footprint.
 

JohnSan

Joined Sep 15, 2018
42
PWM?
CPU?

Luminous intensity of a typical led is almost proportional to forward current. So wouldn't a current source be a better solution?
The ambient light level will of course be relevant to some degree, as to the viewers perception of lowest level of brightness.

The resistor, capacitor & transistor current source, must be the easiest solution with a good presentation of changing intensity?
 
Top