智能小车C语言程序
#include
#include
#define uchar unsigned char
#define uint unsigned int
sbit LeftIR=P1^6;
sbit RightIR=P1^7;
sbit ENA=P1^2; // L298的Enable A
sbit IN1=P1^0; // L298的Input 1
sbit IN2=P1^1; // L298的Input 2
sbit ENB=P1^5; // L298的Enable B
sbit IN3=P1^3; // L298的Input 3
sbit IN4=P1^4; // L298的Input 4
uchar t=0; //中断计数器
uchar motor_1=0,motor_2=0; //电机1,2速度值
uchar tmp1,tmp2; // 电机当前速度值
uchar aa;
bit flag=0; //标志位
void motor(uchar index, char speed)
{