![]() |
PIC Microcontrollers on-line FREE! |
|
Index |
![]() |
|||
|
|
Development systems | ||||||
|
|
Contact us | ||||||
|
|||||||
|
7.2 LED diodes
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 are connected to a microcontroller in two ways. One is to switch them on with logic zero, and other to switch them on with logic one. The first is called NEGATIVE logic and the other is called POSITIVE logic. The next diagram shows how to connect 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. The other way is to connect all anodes to +5V and to deliver logical zero to cathodes.
Connecting LED diodes to PORTB microcontroller The following example initializes port B as output and alternately switches on and off LED diodes every 0.5sec. For pause we used macro pausems, which is defined in the file mikroel84.inc.
|
|
© Copyright 2003. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
|