Escolar Documentos
Profissional Documentos
Cultura Documentos
Beginner Project 2
Connecting LEDs to propelled by a forward voltage The value of the series limit-
charge (see figure 1). Before light ing resistor must be calculated
PICmicro I/O Pins
is produced, however, the forward based on the maximum allowed
voltage across the diode must be LED current and the difference be-
So, you’ve got a great idea for
higher than the internal barrier volt- tween the applied voltage and the
a project using a PICmicro micro-
age of the diode. This point, la- LED’s voltage drop, +VF.
controller and you want to use at
belled +VF (VoltageForward) on the Like any other diode, LEDs
least one LED in your project as a
graph in figure 1, is the point at pass current in the forward direc-
power indicator. Or, maybe, you’ve
which the diode begins to conduct tion, but block current in the re-
set out to design a bar-graph volt-
and produce light. verse direction (see figure 1). What
meter with eight LEDs, or a circuit
It is important to notice that this means is that the LED will only
using seven-segment LED digit
once the voltage across the LED light up if connected with its cath-
displays, or a controller for a poster
reaches +VF the diode conducts ode on the negative side of the cir-
with blinking lights. Connecting
current extremely well. This action cuit, and its anode on the positive
LEDs to PICmicro I/O pins is a
is shown by the sharp rise in the side of the circuit. Too much re-
breeze as long as you know a few
forward current (+I) indicated by verse voltage will also destroy
basic rules, and Ohm’s law.
the near vertial line on the conduc- LEDs and diodes.
tion graph. The LED attempts to The cathode side of an LED is
LED Characteristics
clamp the voltage near +VF and can usually marked with a flat spot on
LED (Light Emitting Diode) be easily destroyed by an excess of the flange that rings the body of the
lamps are electronic diodes that voltage. To protect the LED, a se- diode. The cathode wire is also usu-
produce light. The light is produced ries current limiting resistor should ally shorter that the anode wire of
only when current passes through be added, as shown in figure 2, an LED. Figure 3, below, compares
the diode in the forward direction, below. an LED with its schematic symbol.
Figure 1. The LED conduction curve Figure 2. A typical LED circuit with Figure 3. An LED schematic symbol
shows the safe operating area. a series current limiting resistor. compared with an LED.
put and how to output a pattern on Misc: Battery clip B1, or power sup-
the LEDs connected to Port B. ply wires; printed circuit board; regu-
This assembly code example lator mounting hardware.
was designed to be used in Micro-
Note: Any momentary contact
chip Technology’s MPLAB devel-
switch should work for S1. Y1 crys-
opment environment. Some
changes may be needed in order for tal should be “microprocessor” type.
the assembly code to function with Printed circuit board wiring diagram,
third-party tools. foil (bottom) side, top view.
;Sirius microSystems provides this software on an as is basis, without any
;warranty, either expressed or implied. All Sirius microSystems software is
;provided for educational use only, and Sirius microSystems does not assume
;any liability for damages, either incidental or consequential, arising out of
;the application, use, or misuse of any of its software or hardware products.
;Sirius microSystems reserves the right, without further notice, to make
;changes to any of its software or hardware referred to in this program or
;library program in order to improve its function, design or reliability.
;Description
Initialize bsf STATUS,RP0 ;Select memory register page 1 TRISB is the port
clrf TRISB ;Make Port B output by clearing TRISB control register for
bcf STATUS,RP0 ;Go back to register page 0
Port B.
Main movlw 01010101b ;Move 01010101b into W and
movwf PORTB ;output pattern to LEDs on Port B A sleep instruction puts
a PICmicro to sleep
Done sleep ;Stop executing the program
until it is reset
END