#include<reg52 h="">
sbit LED0 = P1^0;
sbit LED1 = P1^1;
sbit LED2 = P1^2;
sbit LED3 = P1^3;
sbit LED4 = P1^4;
sbit LED5 = P1^5;
sbit LED6 = P1^6;
sbit LED7 = P1^7;
void delayms(unsigned int xms) //参考郭天祥书上的延时函数
{
unsigned int i,j;
for(i=xms;i>0;i--)
for(j=120;j>0;j--);//使用12MHZ晶振
}
void main()
{
while(1)
{
LED0 = 0;
delayms(100);
LED0 = 1;
LED1 = 0;
delayms(100):
LDE1 = 1;
LED2 = 0;
delayms(100):
LDE2 = 1;
LED3 = 0;
delayms(100):
LDE3 = 1;
LED4 = 0;
delayms(100):
LDE4 = 1;
LED5 = 0;
delayms(100):
LDE5 = 1;
LED6 = 0;
delayms(100):
LDE6 = 1;
LED7 = 0;
delayms(100):
LDE7 = 1;
}
}</reg52>
#include <reg52.h>
void delayms(unsigned int xms)
{
unsigned int i,j;
for(i=xms;i>0;i--)
for(j=120;j>0;j--);
}
void main()
{
P1 = 0xfe;
delayms(400);
while(1)
{
unsigned int i;
for(i=0;i<8;i++)
{
P1<<=1;
P1=P1|0x01;
delayms(400);
}
}
}
#include <reg52.h>
void delayms(unsigned int xms)
{
unsigned int i,j;
for(i=xms;i>0;i--)
for(j=120;j>0;j--);
}
void main()
{
unsigned int i;
DS1302 =0;
while(1)
{
P1 = 0xfe;
delayms(400);
i=0;
for(;i<8;i++)
{
P1<<=1;
P1=P1|0x01;
delayms(400);
}
}
}
<span style="font-family:Comic Sans MS;font-size:18px;">#include <reg52.h>
void delayms (unsigned int xms);
void main()
{
unsigned char a,b;
P1 = 0xfe;
while(1)
{
a = P1>>7;
b = P1<<1;
P1 = a|b;
delayms(500);
}
}
void delayms(unsigned int xms)
{
unsigned int i,j;
for(i = xms; i > 0; i--)
for(j = 120; j > 0; j--);
}</span>
<span style="font-family:Comic Sans MS;font-size:18px;">#include <reg52.h>
#include <intrins.h>
void delayms(unsigned int xms)
{
unsigned int i,j;
for(i=xms;i>0;i--)
for(j=120;j>0;j--);
}
void main()
{
P1 = 0xfe;
while(1)
{
P1 = _crol_(P1,1);
delayms(400);
}
}</span>
欢迎光临 中科因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/) | Powered by Discuz! X3.4 |