Raspberry Pi Mobile Robot with Maker Drive

In this tutorial, I’ll share with you on how to build a mobile robot using a Maker Drive and Raspberry Pi. We will use Blynk app to control the robot.  Before we start, you may need to refer to these tutorial :

  1. Getting Started with Maker pHAT
  2. Getting Started with Maker Drive and Raspberry Pi.

Now, let’s do it!


This tutorial use :

  1. Alluminium 2WD TT Robot/Motor Chassis – Purple
  2. Maker Drive
  3. Raspberry PI Zero WH
  4. M3 PCB Stand (Screw & Nut) 15 mm
  5. Jumper Wire

You can make the hardware connection based on the diagram and table below.

Maker Drive : M1ARaspberry Pi: GPIO 17
Maker Drive : M1BRaspberry Pi: GPIO 18
Maker Drive : 5V OUTRaspberry Pi: 5V
Maker Drive : GNDRaspberry Pi: GND
Maker Drive : M2ARaspberry Pi: GPIO 27
Maker Drive : M2BRaspberry Pi: GPIO 22
Maker Drive : VB+Battery Positive
Maker Drive : VB-Battery Negative

Video Reference

Please refer to this video for the hardware connection.

Sample Code

This is the sample code used for this tutorial. Try it!

from gpiozero import LED, Button, Buzzer
import pigpio
import BlynkLib
from time import sleep
pi = pigpio.pi()
BLYNK_AUTH = '923ae9c3e88e45a5a1ec139dbcde9f32'
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
sw1 = Button(21)
sw2 = Button(16)
sw3 = Button(20)
buzzer = Buzzer(26)
M1A = 17
M1B = 18
M2A = 27
M2B = 22
pi.set_mode(M1A, pigpio.OUTPUT)
pi.set_mode(M1B, pigpio.OUTPUT)
pi.set_mode(M2A, pigpio.OUTPUT)
pi.set_mode(M2B, pigpio.OUTPUT)
def valueMap(x, in_min, in_max, out_min, out_max):
return int((x-in_min) * (out_max-out_min) / (in_max-in_min) + out_min)
# Register Virtual Pins
def v0_write_handler(value):
valueX = int(format(value[0]))
valueY = int(format(value[1]))
valueXMap = valueMap(valueX, 0, 255, -255, 255)
valueYMap = valueMap(valueY, 0, 255, -255, 255)
pwmLeft = valueYMap + valueXMap
if pwmLeft > 255:
pwmLeft = 255
elif pwmLeft < -255:
pwmLeft = -255
pwmRight = valueYMap - valueXMap
if pwmRight > 255:
pwmRight = 255
elif pwmRight < -255:
pwmRight = -255
motorSpeed(pwmLeft, pwmRight)
#print('Motor Left: {}'.format(pwmLeft))
#print('Motor Right: {}'.format(pwmRight))
def motorSpeed(speedLeft, speedRight):
if speedLeft > 0:
pi.set_PWM_dutycycle(M2A, speedLeft)
pi.set_PWM_dutycycle(M2B, 0)
pi.set_PWM_dutycycle(M2A, 0)
pi.set_PWM_dutycycle(M2B, abs(speedLeft))
if speedRight > 0:
pi.set_PWM_dutycycle(M1A, speedRight)
pi.set_PWM_dutycycle(M1B, 0)
pi.set_PWM_dutycycle(M1A, 0)
pi.set_PWM_dutycycle(M1B, abs(speedRight))
motorSpeed(0, 0)
buzzer.beep(0.1, 0.1, 1)
while True:
except KeyboardInterrupt:
motorSpeed(0, 0)

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.

1 thought on “Raspberry Pi Mobile Robot with Maker Drive”

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Ultrasonic HC-SR04P Using Raspberry Pi Pico
Object Sense With Servo Using Maker Pi RP2040
Build Otto DIY Robot Using Maker Pi RP2040
Raspberry Pi RP2040 vs STM32F1 vs SAMD21G18 vs ESP32-S2
The Easiest Way to Print Temperature Tower Using Cura 4.9.1 Plugins
Tutorials of Cytron Technologies Scroll to Top