I'm building a formicarium to have below my monitor. With a Pi pico 2 W as controller, powered by a USB3 port on the monitor.
I'm a software developer, but new to electronics.
The schematic below is what I currently have. Allowing me to control both heating and LEDs.
However when I switch the heating, the brightness of the LEDs changes.
How can I stabilize the LED output (current, as I understand it?) and be able to switch the heating?
When measuring, I can see that the Voltage drops by around 100mV - 150mV for each active transistor. (Over V1, so 5V becomes 4.9V) Which leads to a change in current of about 3 mA.
I have a collection of transistors, resistors, LEDs, capacitors and a multimeter. And I would prefer a solution that doesn't involve ordering any extra parts, if at all possible...
The 47 and 100 Ohm resistors are 1W rated.
Transistors are BC337.
5V comes from the Vbus pin on the pico, which is powered by USB.
Lighting: 2x 30cm led filament (2.4 Vf when measured) controlled via PWM using a single transistor. Just want some light that I can control via a web application. Will probably be on most of the day @ around 60 - 80% power (PWM duty cycle)
Heating: 4x 100 Ohm resistors, switched in pairs with a transistor. The goal is to heat a small box (less than 1L, plywood and acrylic) to about a few degrees over room temperature. This should be around 1W of heating, which is overkill, but that is the point. (Testing for future projects)

simulate this circuit – Schematic created using CircuitLab
Edit: This is all on a breadboard at the moment. If I skip the transistors and switch with a jumper wire I get a change in brightness too.
However the transistors seem to amplify the effect.
Edit 2: I cut an old, thick USB cable and used that to power everything.
And I separated the Pico and the heater and the LEDs so they had their own cables to 5V and ground. (instead of sourcing 5V from the Pico's V_bus, I am now providing 5V to it) The voltage drop on the 5V was almost halved like this. But the LEDs were still too flickery for my liking.
The circuit from the accepted answer (using a red LED as a constant-voltage reference) did fix the flickering.



