Using Motor Driver BTS7960 43A on Arduino
This tutorial guides you through plugging and using the BTS7960 43A Motor Driver with an Arduino board. This is a very cheap motor driver with good specs that can handle a powerful motor. I’ve also writen a library that can be downloaded to ease up things.
1. BTS7960-43A Motor Driver
I bought one of them on eBay for only 14 € but there was very little documentation on the internet about how to plug and use this Motor Driver with an Arduino board. So let’s see how to plug it to arduino first.
2. Pluggin the Motor Driver with Arduino
Motor Driver – Arduino
VCC - 5v output GND - GND R_EN - Arduino Digital I/O (can also be connected to +5v) L_EN - Arduino Digital I/O (can also be connected to +5v) RPWM - Arduino analog output LPWM - Arduino analog output
3. Using the Motor Driver
Let’s say we used pins 2 and 3 for PWM and 44, 45 as digital I/O for R_EN and L_EN.
To turn Right we should put on HIGH both R_EN and L_EN and then set an analog value to RPWM between 0 and 255 being 0 stoped and 255 full throttle. So it would look like:
digitalWrite(44,HIGH); digitalWrite(45,HIGH); analogWrite(2,255); <- Turn delay(2000); <-For a bit analogWrite(2,0); <- Stop turn (can also be used a digitalWrite(2, LOW); to set a 0 to the output of the pin)
Turning Left would mean set a value between 0 and 255 for LPWM pin always with the RPWM on 0 or LOW
To stop the motor we should set any PWM pin to 0 and R_EN and L_EN to LOW:
digitalWrite(2,LOW); digitalWrite(3,LOW); digitalWrite(44,LOW); digitalWrite(45,LOW);
To ease things up I wrote a library that can be downloaded from here: BTS7960MotorDriver
To use it you have to declare the object this way:
Ex. BTS7960MotorDriver mypowermotor(44,45,2,3);
To turn Right:
mypowermotor.Ready(); mypowermotor.TrunRight(255); delay(2000); mypowermotor.TurnLeft(255); mypowermotor.Stop();
That’s it. Ready() is not needed if L_EN and R_EN pins are conected to +5v.
Ready() puts L_EN and R_EN on HIGH.
Stop() puts all pins to LOW.
And that’s all. Any comments are welcome.
TODO: define a brake function so motor can be in 2 states free wheeling and braked.