Getting Started with Maker Drive and Raspberry Pi

If you want to use Maker Drive with Raspberry Pi, read this!


Besides interfacing Maker Drive with microcontroller, it also can be controlled by operating system controller like Raspberry Pi. This tutorial will show you how to setup and program your Pi to drive the DC motor using Maker Drive.

You may need to refer this tutorial first:

  1. Getting Started with Maker pHAT
  2. Getting Started with Maker Drive and micro:bit


This video will show you on how to get start with Maker Drive and Raspberry Pi.

Untuk versi Bahasa Melayu, sila rujuk video dibawah.


Below is the list of items used in the video.

Wiring connection table.

Raspberry PiMaker DriveDC MotorBattery
GPIO 17Pin M1A  
GPIO 18Pin M1B  
GPIO 27Pin M2A  
GPIO 22Pin M2B  
 Terminal M1ADC Motor 1 
 Terminal M1BDC Motor 1 
 VB+ Positive
 VB- Negative
 Terminal M2ADC Motor 2 
 Terminal M2BDC Motor 2 

Sample Code

This is sample code used in the video. Please run pigpio daemon on terminal (sudo pigpiod) before run the program.

from gpiozero import LED, Button, Buzzer
import pigpio
from time import sleep
pi = pigpio.pi()
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 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))
def sw1Pressed():
motorSpeed(200, 200)
def sw2Pressed():
motorSpeed(-100, -100)
def sw3Pressed():
motorSpeed(0, 0)
sw1.when_pressed = sw1Pressed
sw2.when_pressed = sw2Pressed
sw3.when_pressed = sw3Pressed
motorSpeed(0, 0)
buzzer.beep(0.1, 0.1, 1)
while True:
except KeyboardInterrupt:
pi.set_PWM_dutycycle(M1A, 0)
pi.set_PWM_dutycycle(M1B, 0)
pi.set_PWM_dutycycle(M2A, 0)
pi.set_PWM_dutycycle(M2B, 0)
view raw hosted with ❤ by GitHub

Thank You


  1. Getting Started With Maker pHAT
  2. Getting Started With Maker Drive and micro:bit
  3. The pigpio Library

Thanks for reading this tutorial. If you have any technical inquiry, please post at Cytron Technical Forum.

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

DIY Digital Alarm Clock Using REKA:BIT With Micro:bit
Display Internet Time (NTP) on micro:bit
DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
Tutorials of Cytron Technologies Scroll to Top