Aim:
Light Emitting Diodes (LED) is the most commonly used components,
usually for displaying pins digital states. Typical uses of LEDs include
alarm devices, timers and confirmation of user input such as a mouse
click or keystroke. The main aim of this project is how to interface a
single LED to 8051 microcontroller.
Light Emitting Diodes (LED) is the most commonly used components,
usually for displaying pins digital states. Typical uses of LEDs include
alarm devices, timers and confirmation of user input such as a mouse
click or keystroke. The main aim of this project is how to interface a
single LED to 8051 microcontroller.
Description:
Interfacing LED:
Fig. 1 shows how to interface the LED to microcontroller. As you can see the Cathode is connected through a resistor to GND & the Anoode is connected to the Microcontroller pin. So when the Port Pin is HIGH the LED is ON & when the Port Pin is LOW the LED is turned OFF.
We now want to flash a LED in 8051 board. It works by turning ON a LED & then turning it OFF & then looping back to START. However the operating speed of microcontroller is very high so the flashing frequency will also be very fast to be detected by human eye.
The 8051 board has eight numbers of point LEDs, connected with I/O Port lines to make port pins high.
Pin Assignment with 8051
Point LEDs 8051 Lines LED Selection Connections
DIGITAL OUTPUTS LED.0 PORTx=0x01 Connect Any one PORT fromP0, P1, P2, P3
LED.1 Px=0x02
LED.2 Px=0x04
LED.3 Px=0x08
LED.4 Px=0x10
LED.5 Px=0x20
LED.6 Px=0x40
LED.7 Px=0x80
Interfacing LED:
Fig. 1 shows how to interface the LED to microcontroller. As you can see the Cathode is connected through a resistor to GND & the Anoode is connected to the Microcontroller pin. So when the Port Pin is HIGH the LED is ON & when the Port Pin is LOW the LED is turned OFF.
We now want to flash a LED in 8051 board. It works by turning ON a LED & then turning it OFF & then looping back to START. However the operating speed of microcontroller is very high so the flashing frequency will also be very fast to be detected by human eye.
The 8051 board has eight numbers of point LEDs, connected with I/O Port lines to make port pins high.
Pin Assignment with 8051
Point LEDs | 8051 Lines | LED Selection | Connections | ||
DIGITAL OUTPUTS | LED.0 | PORTx=0x01 | Connect Any one PORT fromP0, P1, P2, P3 | ||
LED.1 | Px=0x02 | ||||
LED.2 | Px=0x04 | ||||
LED.3 | Px=0x08 | ||||
LED.4 | Px=0x10 | ||||
LED.5 | Px=0x20 | ||||
LED.6 | Px=0x40 | ||||
LED.7 | Px=0x80 |
Block Diagram
Schematic:
Code:
// ***********************************************************
// Project: Interfacing Single LED to 8051
// Author: Code Bloges
// Module description: Operate single LED
// ***********************************************************
#include<reg51.h>
void delay(int);
void main()
{
P2 = 0x01;
}
// ***********************************************************
// Project: Interfacing Single LED to 8051
// Author: Code Bloges
// Module description: Operate single LED
// ***********************************************************
#include<reg51.h>
void delay(int);
void main()
{
P2 = 0x01;
}
Downloads:
The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.
The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.
To download code and proteus simulation click here.
No comments:
Post a Comment