这里只给出主程序,其他程序见前几个实验。
uchar GlintFlag[2] = {0,0};
void Delay(uint n)
{
uint tt;
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
}
void main(void)
{
Initial(); //调用初始化函数
InitKey();
RLED = 0; //开红灯,表示系统工作
while(1)
{
Keyvalue = KeyScan(); //扫键
if(Keyvalue>0)
{
if(Keyvalue == 1)
GlintFlag[0] = !GlintFlag[0];
if(Keyvalue == 2)
GlintFlag[1] = !GlintFlag[1];
};
if(GlintFlag[0]==1)
{
RLED = !RLED; //闪灯
Delay(4000);
}
else
RLED = OFF; //关灯
if(GlintFlag[1]==1)
{
YLED = !YLED;
if(GlintFlag[0] == 0)
Delay(4000);
}
else
YLED = OFF;
}
}
文章评论(0条评论)
登录后参与讨论