求懂C的给力大神 帮帮忙
程序看不是很懂 求能懂的大神注释下 或者教下 感激不尽 感激不尽#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit key1=P1^1; //信号
sbit key2=P1^2; //布防
sbit key4=P1^5; //报警
sbit r_led=P1^3;
sbit g_led=P1^0;
sbit speak=P1^4;
void delay(uint i)
{
uchar j,k;
for(j=0;j<i;j++)
for(k=0;k<120;k++);
}
void main()
{
uint i;
speak=1;
r_led=1;
g_led=1;
while(1)
{
if(key2==0){ //布防
delay(5);
{if(key2==0){
i=0;
while(key2==0);
}}
}
if(key4==0){ //停止
delay(5);
{if(key4==0){
i=1;
while(key4==0);
}}
}
if(i==1){
speak=1;
r_led=1;
g_led=0;
}
if(i==0){
if(key1==0){
delay(5);
if(key1==0){
speak=1;
r_led=0;
g_led=1;
delay(50);
r_led=1;
speak=0;
delay(50);
}
}
}
}
}