MotorDriverBoard
Arduino Uno/Mega2560 MotorDriverBoard
Install / Use
/learn @emakefun/MotorDriverBoardREADME
MotorDriverBoard
MotorDriverBoard is a multi-functional motor drive expansion board developed by Shenzhen Yichuang Space Technology Co., Ltd. specially for Arduino Uno (compatible with Mega2560) robot, motor drive, and multi-channel servo control. This driver board adopts I2C mode control PCA9685 (16-channel PWM output chip). Therefore, there is no corresponding relationship between the motor or servo of the driver board and the IO port of the arduino main board. The PWM control is extended through I2C. For details, please refer to Driver Board Schematic
MotorDrvierBoard for Arduino UNO(Arduino Mega2560)

quick link guide
Common problem Arduino ide library file download Mixly library download Mblock5 library download Mind+ library download MagicBlock Download
Features
- Support 4-way DC motor, the maximum driving current is 3A
- Support to drive 8-way steering gear, with self-recovery fuse to prevent the steering gear from stalling
- Supports driving 2-way 4-wire stepper motors
- Support 4-way encoding motor
- Onboard passive buzzer (A0)
- Onboard 1 RGB full color light (A1)
- Onboard infrared receiver
- 1 i2c interface, 1 PS2X interface, 1 Uart (Bluetooth/wifi module) interface, 1 NRF24L01 wireless module interface
- 1 ultrasonic module interface
- Servo power supply can be switched to external power supply
- Software supports Arduino IDE, Mixly, Mind+, Mblock5, MagicBlock (customizable based on Scratch3.0)

Hardware function introduction
Front display

In order to make the use of this driver board more flexible, to adapt to the requirements of different motors and servo drives, and to make the entire board run stably
We have designed the following power supply schemes. Note that the driver board must be powered by a lithium battery or a UPS power supply above 8.4V 3A, not only the Uno motherboard usb power supply or dry battery power supply
1、Only through the single power supply of the Uno's DC (7~12V) head to the Uno main board, driver board, and servos at the same time.
Application Scenario:
a. DC motor is required to drive below 9V, such as TT motor building block motor, etc., plus sg90/mg90 steering gear
b. When the PS2 controls the 9V~12V motor, in order to ensure the continuous connection of the PS2, it is recommended to use a model aircraft battery or a high-current 21700 lithium battery, and the two 18650 power supply is unstable**
c. The power switch reaches the IN(DC) position, and the jumper cap short-circuits the 5V position

2、Only provide a single power supply to the driver board, Uno main board and steering gear through the binding post. Output the 5V power supply of the driver board to the Uno motherboard
Application scenarios
a. When driving 4-way motors above 12V, such as 370 motors and 520 motors, the steering gear is a low-power steering gear such as sg90/mg90;
b. When the power supply exceeds the 12V voltage of the Uno DC head, we need to use the terminal for power supply, and the power supply range is 6~25V;
c. The power switch is turned to EX, the jumper cap is shorted to the 5V position, and the R24 resistor position on the back needs to be shorted.

3、The main board of Uno is powered by the DC head, and the servo is powered by the terminal independently.
Application scenarios
a. When using MG995/MG996/DS3235/DS3238 and other large torque servos externally, when the number exceeds 2 (it needs to be tested according to the actual situation), we need to supply power to the servos independently
b. The power supply voltage and current of the steering gear are provided according to the parameters of the steering gear
c. The power switch reaches the IN(DC) position, and the jumper cap short-circuits the EX position

Driver library use
Download arduino libraryPlace it in the libraries directory under the Arduino IDE installation directory, and then open the example program by clicking File-->Examples-->Emakefun_MotorDriverBoard.

Basic sample program
gpiotest Control the PCA9685 output port as a normal IO port to output high and low levels
gpio.begin(1000); /*Initialize the output frequency of the io port to 1KHz*/
gpio.setPin(S1, HIGH); /*Pin S1 (S1~S8) output high level*/
gpio.setPin(S1, LOW); /*Pin S1(S1~S8) output low level*/
pwmtest This sample program is to control PCA9685 output port to output PWM waveform
pwm.begin(1500); /*Initialize the output frequency of the io port to 1500Hz*/
pwm.setPin(S1, 1024); /*Pin 1 outputs a PWM wave with a duty ratio(0~4096) of 1024/4096 */
[dc](examples/dc/dc.ino) /*4 DC motor test program*/
mMotor.begin(50); /*Initialize the output frequency of the io port to 50Hz*/
DCMotor_1->setSpeed(200); /*Set the speed to 200*/
DCMotor_1->run(FORWARD);
/*Control the running state of the motor (FORWARD (front), BACKWARD (rear), BRAKE (stop))*/
ps2_test PS2 handle test program
PS2 handle pin description:
| PS2 handle pin | Arduino pins | | -------------- | ------------ | | DAT | D12 | | CMD | D11 | | SEL/ATT | D10 | | CLK | D13 |
Please do not reverse the PS2 installation, the left is the correct installation, the right is the PS2 receiver reversed.

Motor Test Example
DC Four-way DC motor test program
Emakefun_MotorDriver mMotor = Emakefun_MotorDriver(0x60);
Emakefun_DCMotor *DCMotor_1 = mMotor.getMotor(M1);
void setup()
{
Serial.begin(9600);
mMotor.begin(50); /*Initialize the output frequency of the io port to 50Hz*/
}
void loop()
{
// FORWARD
DCMotor_1->setSpeed(200); /*Set the speed to 200, range 0~255*/
DCMotor_1->run(FORWARD); // A total of four states: FORWARD, BACKWARD, BRAKE, RELEASE
}
Wiring diagram display
ServoEight-way steering gear test program
Emakefun_MotorDriver mMotorDriver = Emakefun_MotorDriver(0x60);
Emakefun_Servo *mServo1 = mMotorDriver.getServo(1);
mMotorDriver.begin(50); /*Initialize the output frequency of the io port to 50Hz*/
mServo1->writeServo(0); /*Set the servo angle 0~180*/
Wiring diagram display

Stepper Stepper motor test program
Emakefun_StepperMotor *StepperMotor_1 = mMotorDriver.getStepper(1, 200);
/*Initialize the stepper motor 1, 42, the stepper motor step is 1.8 degrees, so the number of steps in a circle is 200*/
mMotorDriver.begin(1600); /*Set the frequency to the maximum 1526HZ*/
StepperMotor_1->setSpeed(400); /*Set the number of revolutions per minute of the stepper motor to 400. The faster the speed, the smaller the torque. The speed should not be too low, otherwise it will shake seriously*/
StepperMotor_1->step(200, FORWARD, DOUBLE);
/*Drive the stepper motor to move forward 200 steps in a single step. */
/*The driving mode of the motor is full-step DOUBLE, single-step SINGLE, and 1/2-step INTERLEAVE (please refer to the relevant information for the driving principle of the stepping motor) */
Wiring diagram
The parameter wiring of different stepper motors is not necessarily the same, please be sure to first determine the color of each wire of the stepper motor and the corresponding A+ A- B+ B-phase (or A B C D) relationshipThe following diagram is for wiring reference only

Encoder Four-way coding motor test program
| type | parameter | | ----------------------- | ------------------------------------------------------------ | | Rotating speed | Voltage 6V No-load current 70mA No-load axle speed 90RPM<br />Voltage 9V No-load current 150mA No-load axle speed 140RPM<br />Voltage 12V No-load current 190mA No-load axle speed 190RPM | | Output square wave type | AB phase square wave | | base pulse | 12PPR(The motor rotates once and outputs 12 pulses) | | Reduction ratio | 1:90(The shaft rotates once and the motor rotates 90 times) |
From the above parameters, it can be seen that a total of 90x12=1080 pulses need to be counted when the wheel rotates once.
mMotorDriver.begin(); /*Initialize the output frequency of the io port and default to the maximum*/
EncodeMotor_1->setSpeed(100); /*Set the speed to 100*/
EncodeMotor_1->run(BACKWARD);
/*Control the running state of the motor FORWARD , BACKWARD , BRAKE*/
Test that all four encoder motors can rotate. Open the serial port and we need to be able to print out the
Related Skills
node-connect
335.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
335.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.5kCommit, push, and open a PR
