Interfacing of LED 8051

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Interfacing of LED with 8051

Microcontrollers

By Prof. Amit Kshirsagar


8051 I/O Ports
3 A Pin of Port 0

Read latch
TB2

Internal CPU D Q P0.X


bus P1.X pin

Write to latch Clk Q M1

TB1
Read pin

8051 IC
Port 0 with Pull-Up Resistors
4

Vcc
10 K

P0.0
DS5000 P0.1

Port 0
P0.2
8751 P0.3
8951 P0.4
P0.5
P0.6
P0.7
5 A Pin of Port 1

Read latch Vcc


TB2
Load(L1)

Internal CPU D Q P1.X


bus P1.X pin

Write to latch Clk Q M1

TB1
Read pin

8051 IC
6 Writing “1” to Output Pin P1.X

Read latch Vcc


TB2
Load(L1) 2. output pin is
1. write a 1 to the pin Vcc
Internal CPU D Q 1 P1.X
bus P1.X pin

Clk Q 0 M1
output 1
Write to latch

TB1
Read pin

8051 IC
7 Writing “0” to Output Pin P1.X

Read latch Vcc


TB2
Load(L1) 2. output pin is
1. write a 0 to the pin ground
Internal CPU D Q 0 P1.X
bus P1.X pin

Clk Q 1 M1
output 0
Write to latch

TB1
Read pin

8051 IC
LED (Light Emitting Diode)
 The intensity of the light emitted by an LED depends on the amount of
forward current passed through the device. The maximum allowable forward
current is denoted by IFmax.
 When designing an LED circuit, we have to know the typical voltage drop,
VTyp across the device, and the maximum allowable voltage drop, V Fmax.
 The brightness of the emitted light is measured in millicandela (mcd) and this
is usually referenced to the forward current.
 For example, standard red LEDs are quoted to have brightness of 5 mcd when
operated at 10 mA.
Interfacing LED
● Current passing through the LED should be limited to
maximum forward current (IF).
● To find the value of this resistor, we use the forward voltage and
forward current.
● We design a circuit with 5V supply and forward current of
10mA. We use a red LED here.

R = (5 – 2)/10mA = 300 ohms(Use 270 ohms)


Common Cathode Connection
Common Anode Connection
Program for Blinking LED Interfaced with Port1 pins

 ORG 00H
 START: MOV A,#00
 MOV P1,A
 CALL DELAY
 MOV A,#0FF;
 MOV P1,A
 CALL DELAY
 SJMP START
 END
Delay Subroutine

 DELAY: MOV R0, #0FFH


 L2: DJNZ R0, L2
 RET

Delay Calculation

 Instruction No of Bytes
 DELAY: MOV R0, #0FFH 2
 L2: DJNZ R0, L2 3
 RET 3

Delay Generated by Subroutine

 Delay= {(No of M/c Cycle inside loop)*Count + M/c Cycle


count outside loop)} * 1.05uSec.
 Delay= {( 3 ) * 256 + 5 } * 1.05uSec
 Delay= 811.65 uSec =8 mSec
Delay Calculation
 Instruction No of Bytes
 DELAY: MOV R0, #0FFH 2
 L2: MOV R1, #0FFH 2
 L1: DJNZ R1, L1 3
 DJNZ R0, L2 3
 RET 2

You might also like