void XinhaoDuqu_Chuli()
{
static unsigned char old;
unsigned char key;
key = PINE;
if(key != old)
{
USART1_SendChar(key);
old = key;
}
switch(key)
{
case 0XE6://中间和左1
case 0XE2://左1
case 0XE3://左1和左2
case 0XE1://左2
case 0XE7://左1、左2和中间
case 0XEF://左1、左2、中间和右1
Zuozhuan;
TC_OCRnx(0,0,0,0);
PORTC &= ~(_BV(PC0)|_BV(PC2));
break;
case 0XEC: //中间和右1
case 0XE8: //右1
case 0XF8: //右1和右2
case 0XF0: //右2
case 0XFC: //右1、右2和中间
case 0XFE: //右1、右2、中间和左1
Youzhuan;
TC_OCRnx(0,0,0,0);
PORTC &= ~(_BV(PC1)|_BV(PC3));
break;
default:
Qianjin;
TC_OCRnx(0,0,0,0);
PORTC = _BV(PC0)|_BV(PC1)|_BV(PC2)|_BV(PC3);
break;
}
}
这个就是一循迹小车的程序