LED Blinking program in 8051:
8051 is a 8-bit micro-controller. i.e.,it data bus size is 8-bit so that each port in 8051 having 8 pins and having 4 ports Port-0,Port-1,Port-2,Port-3
this example showing the led blinking for Port 1
#include <reg52.h>//header file for 8051 or 8052
void delay(int ch)
{
int i=0,j=0;
for(i=0;i<ch;i++)
{
for(j=0;j<1275;j++)
{
}
}
}
void main()
{
while(1)
{
P1=0x00;
delay(20);
P1=0xff;
delay(20);
}
}
here while(1) is a continues loop (infinity loop)
P1=0x00; means all pins are active low that means zero Volts
P1=0xff; means all pins are active high that means 5 Volts
we are providing a delay of 200 millisec for ON and OFF state
below video shows every thing
8051 is a 8-bit micro-controller. i.e.,it data bus size is 8-bit so that each port in 8051 having 8 pins and having 4 ports Port-0,Port-1,Port-2,Port-3
this example showing the led blinking for Port 1
#include <reg52.h>//header file for 8051 or 8052
void delay(int ch)
{
int i=0,j=0;
for(i=0;i<ch;i++)
{
for(j=0;j<1275;j++)
{
}
}
}
void main()
{
while(1)
{
P1=0x00;
delay(20);
P1=0xff;
delay(20);
}
}
here while(1) is a continues loop (infinity loop)
P1=0x00; means all pins are active low that means zero Volts
P1=0xff; means all pins are active high that means 5 Volts
we are providing a delay of 200 millisec for ON and OFF state
below video shows every thing
No comments:
Post a Comment