#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit IN1=P2^1;
sbit IN2=P2^2;
sbit IN3=P2^6;
sbit IN4=P2^4;
sbit IN5=P1^1;
sbit IN6=P1^2;
sbit IN7=P1^3;
sbit IN8=P1^4;
#define quan_go IN1=1,IN2=0,IN3=1,IN4=0,IN5=0,IN6=1,IN7=1,IN8=0
#define quan_hui IN1=0,IN2=1,IN3=0,IN4=1,IN5=1,IN6=0,IN7=0,IN8=1
#define quan_down IN1=0,IN2=0,IN3=0,IN4=0,IN5=0,IN6=0,IN7=0,IN8=0
#define turn_left IN1=0,IN2=0,IN3=1,IN4=0,IN5=0,IN6=0,IN7=1,IN8=0
#define turn_right IN1=1,IN2=0,IN3=0,IN4=0,IN5=0,IN6=1,IN7=0,IN8=0
uchar a;
void go()
{
quan_go;
}
void hui()
{
quan_hui;
}
void stop()
{
quan_down;
}
void turnleft()
{
turn_left;
}
void turnright()
{
turn_right;
}
void init()
{
TMOD=0x20;
TH1=0xFd;
TL1=0xFd;
SCON=0x50;
PCON=0x00;
TR1=1;
ES=1;
EA=1;
}
void main()
{
init();
while(1)
{
if(a=='A') go();
else if(a=='B') hui();
else if(a=='C')turnleft();
else if(a=='D') turnright();
else stop();
}
}
void serial() interrupt 4
{
a=SBUF;
RI=0;
} |