1: LED with 8051
#include <reg51.h>
//sfr P1 = 0x90;
//sfr P3 = 0xB0;
void delay(unsigned int i)
{
unsigned int j,k;
for(j=0;j<=i;j++)
{
for(k=0;k<256;k++);
}
}
void main(void)
{
unsigned int i,j;
P1 = 0xff;
P3 = 0xff;
while(1)
{
P1 = 0x01;
delay(4000);
for(i=0;i<=10;i++)
{
P1 = P1 << 1;
delay(4000);
}
//P1 = 0x00;
delay(4000);
P1 = 0x80;
delay(4000);
for(j=0;j<=10;j++)
{
P1 = P1 >> 1;
delay(4000);
}
}
}
#include <reg51.h>
//sfr P1 = 0x90;
//sfr P3 = 0xB0;
void delay(unsigned int i)
{
unsigned int j,k;
for(j=0;j<=i;j++)
{
for(k=0;k<256;k++);
}
}
void main(void)
{
unsigned int i,j;
P1 = 0xff;
P3 = 0xff;
while(1)
{
P1 = 0x01;
delay(4000);
for(i=0;i<=10;i++)
{
P1 = P1 << 1;
delay(4000);
}
//P1 = 0x00;
delay(4000);
P1 = 0x80;
delay(4000);
for(j=0;j<=10;j++)
{
P1 = P1 >> 1;
delay(4000);
}
}
}
Comments
Post a Comment