Add functionality to existing project with Attiny85

I have set up WLED on an Wemos D1 Mini (ESP8266) and that works fine. I will build this project innside an enclosure and that enclosure has an RGB led for showing different states.

But i can't install additional code (the easy way) on the flashed Wemos D1 Mini and i need to use an second microcontroller for adding states to the led.

I need the LED to light up red when the switch on the box is turned off, no power is given to microcontrollers. The red light on the RGB LED for showing standby mode must be hard wired.

When the switch is turned on, i want the RGB LED on the box show green light. But in same time i need the red light turn off....

I need some guidelines how to achieve that. The simplest way is to program the Wemos D1 Mini off course, but this is not easy in this case.

Some ruff ideas?

1 Like

A single N-channel small signal mosfet (BSS123, 2n7000 etc) and a few resistors should do the trick. Wire red led anode to a voltage source upstream from the microcontroller's power switch, its cathode to a suitable current limiting resistor which you connect with its other end to the mosfet's drain, feed the Vcc of the microntrollers to the gate and tie mosfet source to GND.

Is your RGB led a common anode or common cathode type?
Can you post a schematic of the setup as it is now?

Thanks. I will try that.

My project is not finished yet so no schematic. It stopped up when i realized that i do not have the possibility to program the Wemos D1 mini when it's flashed with wled.

My RGB led has one ground and three positive legs. So common cathode.

1 Like

Always make a schematic.

Ok, then something like this may work for you:

Thanks. I see what you mean with that circuit.

But i forgot to say that my main input power is 12VDC so i need to add som voltage regulations inn the circuit before Attiny85. I'm not very good drawing chematics, but i will try and add an update here soon...

Here is my Schematic. I'm not good at this, but i will learn.

Chematic deleted...

One error in chematic over i will fix.... One moment....

Here is my last schematic:

Just suggestion.

I think it possible to use an NC type opto-relay instead of the circuit on the left of you provided schematic.
e.g. TLP4227G(mouser)
Although the RED signal from uC will need to be inverted...


But will the schematic i drawed work?

I don't think you need a converter regulator for LEDs.
Also, the signal is inverted.

Can you please explain what you mean? :slight_smile:

You said "regulator" but I thought and saying "converter".
Please read again.
As for the signal, it is the meaning same that described with blue text of my post schematic above.


But how can i invert the red light in the RGB LED? Can you give me an example please? I mean based on the schamitic i drawn over?

I only use one 10mm RGB LED.

If you mean how the red led is driven: it's supposed to be that way. OP explained in his first post, he wants red to be on when power to the uC is off.

It just reverses what your ATtiny's program does.

ex. Thinking of digitalWrite() function...
BLUE and GREEN light up at HIGH and shut off at LOW.
But in the case of these circuit; Only RED, light up at LOW and shut off at HIGH.

Yeah, I know that.
I've had a relationship with OP from past posts, and I think OP quite a beginner.
I want to clarify that the processing is different with red and blue, green.

Ok, all clear!

Thanks mate.

To clarify the processing, you may consider connecting the anode side of the blue and green LEDs to 5V via resistor and connecting the cathode to ATtiny to align the signal processing of three colors.
In that case everything "inverted".

Yes i know that the red led also light when switch is turned on. I can`t digital assign anything to the red led when it's hard wired and not connected to microcontroller. I have to figure that out.

The ble led is added to scematic just because it's an RGB led. I have no plans for the blue led, so far. I just connected it to the attiny85 for now. Maybe i will add an temperature sensor and a led status for that, but this is not important regards to this thread.

My main consern so far is the red led and how i can turn that off when switch is turned on (closed) and the attiny sets the green led HIGH.