I would like to switch a 350mA LED with a transistor. Switching is done by a 5V microcontroller and the main voltage is provided by a 24V power supply. To play around and see what works I used Yenka, so I'll use screenshots from that.
As I understand this is the conventional way to do such a thing – assuming that the LED voltage drop is ~4V, it's connected to the collector along with a resistor to eat up the excess voltage:
However I noticed that in the simulation connecting the LED straight to the 24V supply works as well if we use more resistance to the base:
Shouldn't connecting a 4V LED straight to a 24V supply damage the LED, or do I have some fundamental misunderstanding about this? All answers, thoughts and tips are appreciated, I'm still learning the basics here.
Tl;dr version: will the circuit in the second image work, or is this evil program trying to make me burn my fancy LEDS?