|||
//8个发光管由上而下间隔1s流动,其中每个灯管亮500ms,?
//灭500ms,亮时蜂鸣器响,灭时关闭蜂鸣器,一直重复下去。
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
uchar temp,temp2;
sbit beep=P2^3;
void main()
{
temp=0xfe;
temp2=0xff;
P1=temp;
beep=0;
while(1)
{
delay(75);
P1=temp2;
beep=1;
delay(75);
temp=_crol_ (temp,1);
P1=temp;
beep=0;
}
}
void delay(uint z)
{
uint x, y;
for(x=z;x>0;x--)
for(y=765;y>0;y--) {}
}
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 17:19
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社