You must have already seen how to convert binary decimal into hexadecimal. We are providing a chart which will help you understand how do we glow only specific region of our 7 segment common anode display with 8051 microcontroller.
And here is the source code :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//**************************************************************************************** | |
//www.go8051.com | |
//Chapter 10 | |
//Interfacing 7 Segment(Common Anode) LED Display with 8051 Microcontroller on Breadboard | |
//Created By go8051.com | |
// Open source | |
//email : 8051blog@gmail.com | |
//**************************************************************************************** | |
#include<reg51.h> // Header file for 8051 microcontroller | |
void delay(); // function prototype for delay function( this function will be used to provide a delay in between blinking showing digits) | |
void main() // start of main function | |
{ | |
P2=0; // configure all the pins of Port 1 as output port. All the pin will now act as output port | |
while(1) // infinite while loop | |
{ | |
P2=0xc0; // Send Value 0xc0 on Port 2 which will illuminate the 7 segment display to make it 0 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0xf9; // Send Value 0xf9 on Port 2 which will illuminate the 7 segment display to make it 1 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0XA4; // Send Value 0xA4 on Port 2 which will illuminate the 7 segment display to make it 2 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0XB0; // Send Value 0xB0 on Port 2 which will illuminate the 7 segment display to make it 3 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0X99; // Send Value 0x99 on Port 2 which will illuminate the 7 segment display to make it 4 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0X92; // Send Value 0x92 on Port 2 which will illuminate the 7 segment display to make it 5 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0X82; // Send Value 0x82 on Port 2 which will illuminate the 7 segment display to make it 6 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0XF8; // Send Value 0xF8 on Port 2 which will illuminate the 7 segment display to make it 7 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0X80; // Send Value 0x80 on Port 2 which will illuminate the 7 segment display to make it 8 | |
delay(); // halt for some time after displaying the digit(calling delay function) | |
P2=0X98; // Send Value 0x98 on Port 2 which will illuminate the 7 segment display to make it 9 | |
delay(); | |
} | |
} | |
// this delay function will provide a delay of 1.5 secs approximately | |
void delay() // function definition of delay function | |
{ | |
int i,j; // declaring variable i and j | |
for(i=0;i<=1275;i++) // first for loop which will loop 1275 times | |
for(j=0;j<=1;j++); // second loop which will loop for 2 times(change the delay time '1' to other if you want to increase delay) | |
} |
We are also giving you the zip file of the c source code. Click on the below button to download the c source code of Interfacing 7 Segment(Common Anode) LED Display with 8051 Microcontroller on Breadboard.
No comments:
Post a Comment
Stuck Somewhere ? Comment Your Queries and Experts will Guide You.