Introduction: Motorize Your RaspberryPi

These instructions will add wheels to your Raspberry pi so that you can take your project where no transistor has been before.

This tutorial will walk you through the technical part of how to control the motors through the Wi-Fi Network. As this project was made using spare parts from the famous box of useless plastic pieces that I keep for no reason, you might need to use some creativity to figure out the best way to attach these parts together and design your rover.


  • Raspberry Pi Zero W
  • L293D
  • DC 3V-6V DC Gear Motor for Arduino 3
  • Smart Robot Car wheels
  • Jump wires
  • USB cable
  • Battery holder (4 AA batteries)
  • Breadboard
  • Soldering Iron
  • Screws, tape, glue, anything that holds stuff together.

Step 1: Remote Connection to Your Raspberry Pi Using Wifi

The first goal is to connect remotely to the Raspberry pi (RPi). Assuming that you have already installed the operating system Raspberry Pi OS (available here), you need to:

  1. Connect the RPi to the Wi-Fi
  2. Find its IP Address
  3. Enable the VNC server on the RPi
  4. Download on your smartphone/tablet the app VNC viewer.

1) The first step is straightforward assuming that you have a monitor and a keyboard that you can connect to the RPi, in this case you can use the user interface as you would on a pc. If you can't use a monitor, you need to follow the instructions for the headless setup.

2)Download the software "Advanced IP Scanner" ; click on scan and it will display all devices on your local network and their corresponding IP address.

3) To enable the VNC server you need to open a terminal and run the following command:

sudo raspi-config

Then browse to Interfacing Options, select VNC Server and set it to Enabled. If you are one of those folks without a monitor then you need to perform this step using a SSH connection.

4) Lastly, download the app VNC Viewer on your phone, tap on the "+" icon, type the IP address of your RPi, assign any name to it, and hit connect. The default credentials are:

User: pi Pass: raspberry

Step 2: Understand the Role of the L293D

The pins on the RPi are driven by the 3.3 V rail and supply a max of 16mA on one pin. That is not enough to power a motor. The pins only serve as signals to move each motor forward or backward; according to this input a separate circuit called H-Bridge will switch the polarity of the voltage applied to the motor using AA batteries as a power source. The L293D contains two H-bridges so you can connect two motors to it.

You need to choose 4 pins from the raspberry pi and connect them to the control input pins (7,2,10,15) of the L293D.

Step 3: Wiring

Attach the RPi and the L293D to the breadboard; attach the L293D in the middle of the breadboard so that each one of its pins is on an independent line. Then complete the wiring using the jump wires.

Step 4: Some Soldering...

There are few soldering tasks required:

  • You need to solder 2 jump wires to each motor and connect these to the corresponding pin on the L293D.
  • You need to attach the battery holder power (5V) and ground wire to the corresponding wires on the USB cable so that you can power up you RPi using batteries.

Step 5: Upload the Software

Power up you raspberry pi and connect to it.

The remote interface was designed using tkinter in python.

Install this library running the command

sudo apt-get install python3-tk

Create a new file called and copy-paste the code attached.

The interface buttons are linked to these 4 functions below which set control pins to either HIGH or LOW in different configurations:

def Fw():
GPIO.output(20, GPIO.LOW)
GPIO.output(21, GPIO.LOW)
GPIO.output(23, GPIO.HIGH)
GPIO.output(24, GPIO.HIGH)

def Bk():
GPIO.output(20, GPIO.HIGH)
GPIO.output(21, GPIO.HIGH)
GPIO.output(23, GPIO.LOW)
GPIO.output(24, GPIO.LOW)

def Stop():
GPIO.output(20, GPIO.LOW)
GPIO.output(21, GPIO.LOW)
GPIO.output(23, GPIO.LOW)
GPIO.output(24, GPIO.LOW)

def Left():
GPIO.output(20, GPIO.LOW)
GPIO.output(21, GPIO.LOW)
GPIO.output(23, GPIO.HIGH)
GPIO.output(24, GPIO.LOW)
def Right():

GPIO.output(20, GPIO.LOW)
GPIO.output(21, GPIO.LOW)
GPIO.output(23, GPIO.LOW)
GPIO.output(24, GPIO.HIGH)

When ready to run a test, open a new terminal window, browse to the file location and run the command:


Step 6: Design Your Rover

Finally you can decide what your rover will look like... I had some hardboard pieces, a plastic hamster ball that looks like R2D2, a spare snapshot camera that I connected to the TX RX pin (but if you are planning to attach a camera then use the main camera interface so you get a live video instead)

I didn't have a third wheel so I had to improvise. I 3d-printed some pieces to hold everything together, I leave them attached if you need them

Make it Move Contest 2020

Participated in the
Make it Move Contest 2020