#include <intrins.h>//包含有则让左右循环移位子函数的库
#define uint unsigned int
#define uchar unsigned char void delay(uint z) //延时函数,z的取值为这个函数的延时ms数
{
uint x,y
for(x=zx>0x--)
for(y=110y>0y--)
}
void main() //主函数
{
uchar a,i,j
while(1)
{
for(j=0j<3j++) //寄偶交替
{
P1=0x55
delay(300)
P1=0xaa
delay(300)
}
for(j=0j<3j++)//流汪碰水灯
{
a=0xfe
for(i=0i<8i++)
{
P1=a
delay(300)
a=_crol_(a,1)
}
}
P1=0xff
for(j=0j<3j++) //从两边往中间流
{
P1=0x7e
delay(300)
P1=0xbd
delay(300)
P1=0xdb
delay(300)
P1=0xe7
delay(300)
}
P1=0xff
for(j=0j<3j++)//从中间往两边流
{
P1=0xe7
delay(300)
P1=0xdb
delay(300)
P1=0xbd
delay(300)
P1=0x7e
delay(300)
}
P1=0xff
for(j=0j<6j++)
{
P1=~P1
delay(300)
}
P1=0xff
}
}你试下行不行,是11.0592MHz的,时间上接近,但不精困盯谈确的!
//流水灯#include "reg52.h"
#define LED_PORT P3
void delay(unsigned char time)
{
unsigned char i,j,k
for(i=0i<timei++)
{
for(j=0j<200j++)
{
for(k=0k<200k++)
灶禅}
}
}
void main()
{
unsigned char i,halfbyteh=0x80,halfbytel=0x01
while(1)
{
halfbyteh=0x80
halfbytel=0x01
for(i=0i<8i++)
{
宴桥 //LED_PORT=halfbyteh|halfbytel//高电平点亮
LED_PORT=~(halfbyteh|halfbytel)//低电平点亮
halfbyteh=halfbyteh>>1
halfbytel=halfbytel<<1
晌辩猛delay(10)
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)