|||
//8个发光管来回流动,每个管亮100ms,流动时蜂鸣器发出"滴滴"声
#include <intrins.h>
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
uchar temp,temp2;
sbit beep=P2^3;
void main()
{
temp=0xfe;
beep=0;
P1=temp;
while(1)
{
delay(15);
temp=_crol_ (temp,1);
beep=0;
P1=temp;
}
}
void delay(uint z)
{
uint x, y;
beep=1;
for(x=z;x>0;x--)
for(y=765;y>0;y--) {}
}
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 13:37
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社