Samples
Light-Emitting Diodes - LEDs
LEDs are surely one of the most commonly used elements in electronics. LED
is an abbreviation for 'Light Emitting Diode'. When choosing a LED, several
parameters should be looked at: diameter, which is usually 3 or 5 mm
(millimeters), working current which is usually about 10mA (It can be as
low as 2mA for LEDs with high efficiency - high light output), and color
of course, which can be red or green though there are also orange, blue,
yellow....
LEDs must be connected around the correct way, in order to emit light and
the current-limiting resistor must be the correct value so that the LED is
not damaged or burn out (overheated). The positive of the supply is
taken to the anode, and the cathode goes to the negative or ground of the
project (circuit). In order to identify each lead, the cathode is the
shorter lead and the LED "bulb" usually has a cut or "flat" on
the cathode side. Diodes will emit light only if current is flowing from
anode to cathode. Otherwise, its PN junction is reverse biased and current
won't flow. In order to connect a LED correctly, a resistor must be added
in series that to limit the amount of current through the diode, so that
it does not burn out. The value of the resistor is determined by the
amount of current you want to flow through the LED. Maximum current flow
trough LED was defined by manufacturer. High-efficiency LEDs can produce a very good output with a
current as low as 2mA.
To determine the value
of the dropper-resistor, we need to know the value of the supply
voltage. From this we subtract the characteristic voltage drop of a
LED. This value will range from 1.2v to 1.6v depending on the color
of the LED. The answer is the value of Ur. Using this value
and the current we want to flow through the LED (0.002A to 0.01A) we
can work out the value of the resistor from the formula R=Ur/I.
|
|
LEDs are connected to a microcontroller
in two ways. One is to turn them on with logic zero, and other to turn
them on with logic one. The first is called NEGATIVE logic and the other
is called POSITIVE logic. The above
diagram shows how they are connected for POSITIVE logic. Since POSITIVE
logic provides a voltage of +5V to the diode and dropper resistor, it will
emit light each time a pin of port B is provided with a logic 1 (1 = HIGH
output). NEGATIVE logic requires the LED to be turned around the other way
and the anodes connected together to the positive supply. When a LOW output from
the microcontroller is delivered to the cathode and resistor, the LED will
illuminate.
Connecting LED diodes to PORTB microcontroller
The following example initializes port B as output and sets logic one to
each pin of port B to turn on all LEDs.
|