基于arduino的5路循迹小车(1)
初步小车运动
1.硬件选用
1.开发板使用arduino 2560
2.电机驱动板使用 大功率电机驱动板(PWM由两个端子控制)
3.电源12V锂电池
4.降压板(需要降压给开发板供电)
5.直流减速电机12V
2.接线
12V电源直接给通过电机驱动板给电机供电
12V电源通过降压板给开发板供电
其余控制电路接线均按代码接线
(注意:12V电源接出的线因电流过大,需要使用漆包线,其余均可用杜邦线)
3.代码
int Left_motor_go1 = 24; //左电机前进 AIN1
int Left_motor_back1 = 25; //左电机后退 AIN2
int Right_motor_go1 = 22; //右电机前进 BIN1
int Right_motor_back1 = 23; //右电机后退 BIN2
int Left_motor_pwm1 = 3; //左电机控速 PWMA1
int Right_motor_pwm1= 5; //右电机控速 PWMB1
int Left_motor_pwm2 = 4; //左电机控速 PWMA2
int Right_motor_pwm2= 6; //右电机控速 PWMB2
void setup()
{
//初始化电机驱动IO口为输出方式
pinMode(Left_motor_go1, OUTPUT);
pinMode(Left_motor_back1, OUTPUT);
pinMode(Right_motor_go1, OUTPUT);
pinMode(Right_motor_back1,