Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Waveshare

Waveshare Motor Driver HAT: Raspberry Pi Robot Control

Waveshare Motor Driver HAT: Raspberry Pi Robot Control

April 1, 2026 /Posted by / 0

Building a robot with Raspberry Pi? The Waveshare Motor Driver HAT provides dual H-bridge motor control plus servo outputs directly on the GPIO header.

Table of Contents

  • Features
  • Hardware Setup
  • Python Control
  • Servo Control
  • Robot Build
  • PID Speed Control
  • FAQ

Features

  • TB6612FNG dual H-bridge, 1.2A continuous/channel
  • 2-4 servo channels via PCA9685 PWM controller
  • I2C interface (0x40), uses only 2 GPIO pins
  • Separate motor power input (6-12V)
  • Reverse polarity protection, thermal shutdown
Recommended: Waveshare Aluminum Heatsink for Raspberry Pi 5

Hardware Setup

  1. Mount HAT on Pi GPIO header.
  2. Connect DC motors to M1/M2 terminals.
  3. Connect servos to servo headers.
  4. Connect 6-12V battery to motor power input.
  5. Power Pi separately via USB-C.

Critical: Use separate power for motors to avoid brownouts.

Python Motor Control

from adafruit_pca9685 import PCA9685
from adafruit_motor import motor
import busio, board, time
i2c = busio.I2C(board.SCL, board.SDA)
pca = PCA9685(i2c); pca.frequency = 1000
m1 = motor.DCMotor(pca.channels[0], pca.channels[1])
m2 = motor.DCMotor(pca.channels[2], pca.channels[3])
m1.throttle = 1.0; m2.throttle = 1.0  # Forward
time.sleep(2)
m1.throttle = -0.5; m2.throttle = -0.5  # Reverse half
time.sleep(2)
m1.throttle = 0; m2.throttle = 0  # Stop

Servo Control

from adafruit_motor import servo
pca.frequency = 50
s1 = servo.Servo(pca.channels[14])
s1.angle = 0; time.sleep(1)
s1.angle = 90; time.sleep(1)
s1.angle = 180
Recommended: Waveshare Aluminium Alloy Case for Pi 5, Dual Cooling Fans

Robot Build Guide

Line-Following Robot: Pi 4 + Motor HAT + 2x BO motors + 3-channel IR sensor + 7.4V LiPo.

import RPi.GPIO as GPIO
L,C,R = 17,27,22
GPIO.setmode(GPIO.BCM)
for p in [L,C,R]: GPIO.setup(p, GPIO.IN)
while True:
    if not GPIO.input(C): m1.throttle=0.6; m2.throttle=0.6
    elif not GPIO.input(L): m1.throttle=0.3; m2.throttle=0.7
    elif not GPIO.input(R): m1.throttle=0.7; m2.throttle=0.3
    else: m1.throttle=0; m2.throttle=0

PID Speed Control

Add optical encoders and implement PID: P corrects current error, I corrects accumulated error, D dampens oscillation. Start with Kp=0.5, add Ki=0.1, then Kd=0.05.

Frequently Asked Questions

Can I control steppers?

Small bipolar steppers up to 1.2A per coil. Use A4988 for larger steppers.

How many motors?

Two DC + up to 4 servos. Chain PCA9685 HATs for more.

Works with Pi 5?

Yes, GPIO header compatible. Use latest Adafruit CircuitPython libraries.

Motors stutter at low speed?

TB6612 PWM at very low duty cycles may not overcome static friction. Set minimum throttle to 0.3.

Conclusion

The Waveshare Motor Driver HAT is the simplest way to add motor control to Pi robots. HAT form factor eliminates messy wiring, and Python libraries make control straightforward.

Browse the full Waveshare collection at Zbotic.in with fast shipping across India.

Tags: motor driver, Raspberry Pi, Robotics, waveshare
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Banana Plug: Test Lead and Spe...
blog banana plug test lead and speaker wire connectors 614029
blog waveshare relay hat control ac loads from raspberry pi 614035
Waveshare Relay HAT: Control A...

Related posts

Svg%3E
Read more

Waveshare Firmware Update: Flash Latest Software Guide

April 1, 2026 0
Many Waveshare products contain updatable firmware. Keeping firmware current fixes bugs and adds features. Table of Contents Which Products Need... Continue reading
Svg%3E
Read more

Waveshare Troubleshooting: Common Issues and Fixes

April 1, 2026 0
Even reliable hardware encounters issues. This guide addresses the most common Waveshare problems and their solutions. Table of Contents Display... Continue reading
Svg%3E
Read more

Waveshare Education Kit: Classroom Raspberry Pi Pack

April 1, 2026 0
The Waveshare education kit is designed for STEM classrooms, with structured lessons from basic to advanced. Table of Contents Kit... Continue reading
Svg%3E
Read more

Waveshare Industrial Kit: RS485, CAN, and 4G Bundle

April 1, 2026 0
The Waveshare industrial kit combines RS485, CAN bus, and 4G for connecting legacy factory equipment to modern cloud platforms. Table... Continue reading
Svg%3E
Read more

Waveshare Weather Kit: Environmental Monitoring Bundle

April 1, 2026 0
The Waveshare weather kit bundles environmental sensors for building a complete weather monitoring station. Table of Contents Sensors Included Setup... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now