电机接线图
电机参数如下所示
模块原理图
驱动时序
简单粗暴的来一下
uint32_t delay_time =1;
#define IN1 19
#define IN2 18
#define IN3 12
#define IN4 1
void setup() {
// put your setup code here, to run once:
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(IN1, LOW );
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, HIGH);
delay(delay_time);
digitalWrite(IN1, LOW );
digitalWrite(IN2, LOW );
digitalWrite(IN3, HIGH);
digitalWrite(IN4, HIGH);
delay(delay_time);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW );
digitalWrite(IN3, HIGH);
digitalWrite(IN4, HIGH);
delay(delay_time);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW );
digitalWrite(IN3, LOW );
digitalWrite(IN4, HIGH);
delay(delay_time);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW );
digitalWrite(IN4, HIGH);
delay(delay_time);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW );
digitalWrite(IN4, LOW );
delay(delay_time);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW );
delay(delay_time);
digitalWrite(IN1, LOW );
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW );
delay(delay_time);
}
经过测试效果很好
|