#define ENABLE_INT IE=0x90;
sbit mt11 = P2^0;
sbit mt12 = P2^1;
sbit mt13 = P2^2;
sbit mt21 = P2^3;
sbit mt22 = P2^4;
sbit mt23 = P2^5;
void serial_init(void)
{
TMOD=0x20;
SCON=0x50;
TH1=0xfd;
TR1=1;
}
void transmit_byte(unsigned char x)
{
SBUF=x;
while(!TI);
TI=0;
}
void transmit(unsigned char *string)
{
while(*string)
transmit_byte(*string++);
}
unsigned char recieve(void)
{
unsigned char temp;
while(!RI);
RI=0;
temp=SBUF;
return(temp);
}
void main()
{
P2=0x00;
serial_init();
ENABLE_INT ;
transmit_byte('i');
//transmit("welcome");
while(1)
{
switch(recieve())
{
case '0':
mt11=1;
mt12=0;
mt13=1;
break;
case '1':
mt11=0;
mt12=1;
mt13=1;
break;
case '2':
mt11=0;
mt12=0;
mt13=0;
break;
case '3':
mt21=1;
mt22=0;
mt23=1;
break;
case '4':
mt21=0;
mt22=1;
mt23=1;
break;
case '5':
mt21=0;
mt22=0;
mt23=0;
break;
case 'f':
mt11=1;
mt12=0;
mt13=1;
mt21=1;
mt22=0;
mt23=1;
break;
case 'r':
mt11=0;
mt12=1;
mt13=1;
mt21=0;
mt22=1;
mt23=1;
break;
case 's':
mt11=0;
mt12=0;
mt13=0;
mt21=0;
mt22=0;
mt23=0;
break;
default:
mt11=0;
mt12=0;
mt13=0;
mt21=0;
mt22=0;
mt23=0;
break;
}
}
}
HOST UNIT DIAGRAM