How to assemble Raspberry Pi Robot

Welcome back! This is the second part of the series “How to build a Raspberry Pi Robot” and it will show you how to assemble Raspberry Pi robot. If you have not checked out the previous post check it out here.

Assemble Robot kit

The first thing to assemble is the Robot Kit. I did not find any assemble instructions in the package but I found a PDF on Joy It website which was helpful. You can find it here.

Before you assemble the robot kit, make sure you solder the wires to the DC motors.

I assembled the Robot Kit and you can see in the above images how my robot looks like. A good thing with this robot kit is that there are so many options where you can mount your components. If you find a better way to do this than I did, go for it!

Connect the wires for the robot

In my opinion the assemble of the Robot was the easy part. This next part was the tricky one, connecting all the wires togehter. The following wires should be connected from the Raspberry Pi to the L293D chip.

5V -> Vss 
Ground -> To all 4 GND 
GPIO 25 -> ENABLE1 
GPIO 24 -> INPUT1
GPIO 23 -> INPUT2 
GPIO 16 ->ENABLE2
GPIO 27 -> INPUT4
GPIO 22 -> INPUT3
Connect the Output 1-4 to the DC motors.
Connect the Vs to the power of batteries.
L293D Motor driver
Map of how the wires should be connected

Since Raspberry Pi is most commonly powered using a microUSB connector. However in this project I was not interested in having a chord following my robot. It should run freely. Therefor I am using a LiPO Shim instead to power the Raspberry Pi on batteries instead.

The bad thing about LiPO Shim is that you need to solder the pieces together but when soldering is done all you need to do is place it on top of the GPIO pins and it just works.
Even though I am not the best at soldering I managed to get it together and it works!

When everything is ready and assembled you should be able to run the following Python script and you will see the robot moving.

import RPi.GPIO as GPIO
from time import sleep


GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(True)

Motor1 = {'EN': 25, 'input1': 24, 'input2': 23}
Motor2 = {'EN': 16, 'input1': 27, 'input2': 22}

for x in Motor1:
    GPIO.setup(Motor1[x], GPIO.OUT)
    GPIO.setup(Motor2[x], GPIO.OUT)

EN1 = GPIO.PWM(Motor1['EN'], 100)
EN2 = GPIO.PWM(Motor2['EN'], 100)

EN1.start(100)
EN2.start(100)

while True:

    GPIO.output(Motor1['input1'], GPIO.LOW)
    GPIO.output(Motor1['input2'], GPIO.HIGH)

    GPIO.output(Motor2['input1'], GPIO.HIGH)
    GPIO.output(Motor2['input2'], GPIO.LOW)

    sleep(0.1)

GPIO.cleanup()

What’s next?

This tutorial has shown you how to assemble your very own Raspberry Pi Robot and it now moves 😀

I have not decided yet what my next plan is for this Robot, I might think about steering the robot via a UI or adding a camera. If you have an idea what you think I should do next, please comment!