|
#include<at89x51.h>
void delay(unsigned char a)
{
unsigned char j,y;
for(j=0;j<a;j++)
for(y=0;y<115;y++);
}
void main()
{
unsigned char x;
P0=0x00;
while(1)
{
/**********************************/
P1=0xff;
x=P1;
x=~x;
if(x==0)continue;delay(10);
x=P1;
x=~x;
if(x==0)continue;
if(P1_0==0)/*****左转****/
{
P0=0x15;delay(100);P0=0x00;delay(100);}
else if(P1_1==0)/**右转**/
{P0=0x2a;delay(100);P0=0x00;delay(100);}
else if(P1_2==0)/**刹车**/
{while(P1_2==0){P0=0x30;}P0=0x00;}
else if(P1_3==0)/**紧急**/
{P0=0x3f;delay(100);P0=0x00;delay(100);}
else
P0=0x00;
}
}
|
|