Motor Driver

This documentation includes installation guidelines and sample code for your hardware.

Overall Info

The TC78H630FNG is H-bridge driver IC for DC motors.

Driver Connections

  • Left Motor Driver

    • nStand By: D1

    • Forward PWM: D3

    • Reverse PWM: D2

  • Right Motor Driver

    • nStand By: D0

    • Forward PWM: D5

    • Reverse PWM: D4

  • Power

    • Logic: VCC (+3.3V) and GND.

    • Motor: Motor In and GND.


TC78H630FNG's technical specifications are as follows:

  • Input Voltage: 15V Max.

  • Output Current: 1.6A Max.

  • Control Logic Frequency: 500kHz Max.

Arduino Library

Turta_MotorDriver library is responsible for controlling the motor drivers.

To use the library on Arduino IDE, add the following #include statement to the top of your sketch.

#include <Turta_MotorDriver.h>

Then, create an instance of the Turta_MotorDriver class.

Turta_MotorDriver md

Now you're ready to access the library by calling the md instance.


To initialize the module, call the begin method.


This method configures the GPIO pins to control motors.

Basic Members

Driver Motors

Drives the motors in desired speed and directions.

void driveMotors(int16_t leftSpeed, int16_t rightSpeed)
  • Parameters

    • int16_t leftSpeed: Left motor speed. -255 to 255. 0 is coast.

    • int16_t rightSpeed: Right motor speed. -255 to 255. 0 is coast.

  • Returns

    • None.

Coast Motors

Coasts (stops) the motors without braking.

void coastMotors()
  • Parameters

    • None.

  • Returns

    • None.

Brake Motors

Brakes the motors.

void brakeMotors()
  • Parameters

    • None.

  • Returns

    • None.


You can open the example from Arduino IDE > File > Examples > Examples from Custom Libraries > Turta MKR Motor Shield. There is one example of this sensor.

Motor Driver Demo

This application demonstrates motor control capabilities of the drivers.

To run the example:

  1. Open the Motor Driver Demo sketch from the examples menu.

  2. Select your Arduino MKR series board from the Tools > Board menu.

  3. Select your device's COM port from Tools > Port menu.

  4. Upload the code to your device.

Sample Code

#include <Turta_MotorDriver.h>

// Create Motor Driver instance
Turta_MotorDriver md;

void setup() {
  // Initialize Motor Driver

void loop() {
  // Increase motor speed from coast to maximum forward
  for (short i = 0; i < 255; i++) {
    md.driveMotors(i, i);

  // Set motor speed to maximum forward
  md.driveMotors(255, 255);

  // Decrease motor speed from maximum forward to coast
  for (short i = 255; i > 0; i--) {
    md.driveMotors(i, i);

  // Coast motors
  md.driveMotors(0, 0);

  // Set motor speed to half reverse
  md.driveMotors(-128, -128);

  // Set motor speed to maximum reverse
  md.driveMotors(-255, -255);

  // Set motor speed to half reverse
  md.driveMotors(-128, -128);

  // Short brake motors


After the application is uploaded to the device, it demonstrates different motor speed and directions.

The application runs forever until you clear it from memory.

Last updated