LED interfacing is the main thing, one would attempt to do while beginning with any microcontroller. So here in this instructional exercise we are going to interface a LED with 8051 microcontroller, and will compose a C Program to flicker the LED. We have utilized an extremely prevalent microcontroller AT89S52, of 8051 family, by ATMEL.
Before really expounding, we ought to get some short thought regarding microcontroller AT89S52. It is 40 pin microcontroller, and has 4 ports (P0,P1,P2,P3), every port have 8 pins. We can consider every port as 8 bit register, from the product perspective. Every pin having one Input/yield line, implies each pin can be utilized for contribution and additionally for yield, i.e. to peruse information shape some gadget like sensor or to give its yield to some yield gadget. Some pins have the Dual usefulness, which has been said in section in Pin Diagram underneath. Double practically like for intrude on, counters, clocks and so forth.
Circuit Diagram :
Code:
// C Program for LED Interfacing with 89S52 8051 Microcontroller
#include <REGX52.h>
delay(unsigned int y)
{
unsigned int i,j;
for(i=0;i<y;i++)
{
for(j=0;j<1275;j++)
{
}
}
}
main()
{
while(1)
{
delay(100);
P1_0 = 0;
delay(100);
P1_0 = 1;
}
}
ASSEMBLY LANGUAGE PROGRAM :
ORG 00H
MAIN: MOV P1,#0FFH
LOOP1: CPL P1.0
DELAY:DJNZ R1,DELAY
DJNZ R0,DELAY
JMP LOOP1
For any question coment below or click here for further information