|
The circuit to the left shows a really quick way of
connecting an LED to a 8052. You can connect this circuit up very quickly
and dumb a program on the microcontroller to flash it on and
off. Pros Cons
This circuit shows a better way of connecting an LED using a NPN Transistor, in this case I have used a 3906, which can handle around 100mA which is plenty for what we want. Here the LED is off when the micrcontroller starts, and will be switched on by writing ZERO to the port. It can be turned off again by writing a ONE to the port. The main benefit of this configuration is that it is only using one extra component, but it does allow a lot more current to flow through the LED. In the case of the 3906, it will allow at least 100 times as much current through the LED as is flowing from the port to ground. This mean you'll burn out the LED not your microcontroller. A 330 Ohm resistor should be plenty for our needs here. But you can always lower the value if you want a make the LED brighter. Pros
Cons
More components that you can shake a stick at with this one, who'd have though you would need so much to do so little. To be honest, I've put this one in to show you can have many variations on the theme here. This particular circuit decouples the LED drive from the microcontroller. It uses a transistor to switch on another transistor which drives the LED. Pros
Cons
This circuit is slightly simpler than the one above, it must still use the regulated supply, but it has the advantage of having the LED off when it powers up, which looks slightly more professional. Write a ZERO to the port pin to switch it on and a ONE to switch it on. The 270 Ohm resistor is responsible for the brightness of the LED in this circuit. Pros
Cons
Lots of people will tell you to just us a NPN instead of an PNP or vice versa, and turn bits of the circuit upside down, here's what they mean. The other side-effect of doing this is that the LED will be ON at power on, and you write a ZERO to switch it off and a ONE to switch it ON. The 270 Ohm resistor is, again, responsible for the brightness of the LED in this circuit. Pros
Cons
In this circuit, we've replaced the 10K resistor with a zener diode, which has a breakdown voltage of about 2.2 volts. We've also moved the 270 Ohm resistor below the transistor and made it 100 Ohms. You supply this circuit with any voltage you like, and as long as the transistor can dissapate the power you'll be fine. For example 12V would be no problem at all for this circuit. What's so different? Well in the other circuits, you couldn't add anymore LEDs in this one you can chain a load of them together, and they will all be a constant brightness. They will simply draw more power from the supply. So if you put 10 LEDs in there they will be as bright as 1 LED in the previous circuit. The 100 Ohm resistor and the zener diode are responsible for the power through the LED(s) Pros
Cons
There are many types of LED available, what I call the 'standard' LED is the mass produced red LED, which has a voltage drop of about 2 volts, and draws about 15-20mA. Other types are available, for example the Agilent HLMP-17xx, at 3mA they are as bright as most 'standard' LEDs. If you used one of these in the first circuit a 1K resistor would be needed. Summary As you can see there are lots of options for getting an LEd to light up, personally I use the first one, it's simple and I can remove it from the circuit if I need the pin it is using. Questions or comments? post them here. Back to my homepage Back to the 8052 user homepages Back to the 8052 homepage |



