我这个程序有什么问题???
#include <reg52.h>#define uchar unsigned char
#define uint unsigned int
sbit dula = P2^6;
sbit wela = P2^7;
sbit dawr = P3^6;
sbit dacs = P3^2;
sbit beep = P2^3;
uint m;
void delay(uint z)
{
uint i,j;
for(i = z;i > 0;i--)
for(j = 110;j > 0;j--);
}
void main()
{
uchar val,flag;
dula = 0;
wela = 0;
dacs = 0;
dawr = 0;
P0 = 0;
while(1)
{
for(m = 0;m < 3;m++)
if(flag == 0)
{
val += 5;
P0 = val;
if(val == 255)
{
flag = 1;
}
delay(30);
}
else
{
val -= 5;
P0 = val;
if(val == 0)
{
flag = 0;
}
delay(30);
}
if(m == 2)
{
flag = 0;
delay(9000);
beep = 0;
delay(100);
beep = 1;
}
}
}
我是想实现让D12灯均匀亮灭三次一共9秒,在三次之后蜂鸣器警报一次,但是我这个做了他只会到亮之后不灭了就一直最亮,然后蜂鸣器是可以9秒之后响一次。