0% found this document useful (0 votes)
6 views

Buggy project

This document provides detailed instructions for assembling a robot using a Raspberry Pi, motor controller board, and motors. It covers soldering wires to motors, connecting them to the motor controller, powering the motors with batteries, and wiring the board to the Raspberry Pi GPIO pins. Additionally, it includes steps for testing motor directions and assembling the robot chassis using a cardboard box as a temporary solution.

Uploaded by

piwile2631
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Buggy project

This document provides detailed instructions for assembling a robot using a Raspberry Pi, motor controller board, and motors. It covers soldering wires to motors, connecting them to the motor controller, powering the motors with batteries, and wiring the board to the Raspberry Pi GPIO pins. Additionally, it includes steps for testing motor directions and assembling the robot chassis using a cardboard box as a temporary solution.

Uploaded by

piwile2631
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assembling the motors and board

The first thing you will want to do is to connect your motor controller board to
your Raspberry Pi, the battery pack, and your two motors, to test that they are all
working.

The instructions here are for L298N Dual H Bridge DC Stepper Motor Driver
Controller Board, and they will be pretty similar for most motor controller boards.
Check the documentation for your board if you are using a different one.

Soldering wires to your motors


Most motors you can buy don’t have wires, so you will need to solder these on.

Remove the plastic clip from the motor to make soldering to the contacts easier.
You can do this with a screwdriver.

Solder the wires to each of the terminals on the motor. It doesn’t matter which
wire goes to which terminal.
Then reattach the plastic clips.

Trim the tips of the wires to ensure they do not touch the metal casing of the
motor.
It’s also a good idea to wrap the ends of the motors in tape, to stop the soldered
joints from breaking.

Connect the motors to the board


You will need to connect the motors to the board. For this you will require a small
screwdriver.

Using a screwdriver, loosen the screws in the terminal blocks labeled OUT1, OUT2,
OUT3, and OUT4.
Have a look at the documentation for your board if your labels are different.
Strip the ends of the wires (you can snip off the male or female ends if you need
to) and insert the stripped ends of wire into the terminal blocks.

Tighten the screws up so that the wires are held firmly in the terminal blocks.

Powering the motors


The motors require more power than the Raspberry Pi can provide. Therefore, you
will use four AA batteries to power them.

Loosen the screws in the terminal blocks labeled VCC, GND, and 5V.
Take the AA battery holder and insert the red wire into the VCC terminal block.
The black wire goes into the GND block.
It is important that you get this the correct way around.

Tighten the screws so that the wires are held firmly in place.

Connecting the board to your Raspberry Pi


The board used in this project needs to be wired to the Raspberry Pi. Other boards
may connect differently, and some boards can simply be placed onto the Raspberry Pi
GPIO pins as a HAT. Make sure you look at the documentation for your board to see
whether this is the case.

On the board used here there are pins labeled In1, In2, In3, and In4, as well as
two GND pins. Which GPIO pins on your Pi that you use is up to you; in this
project, GPIO 7, 8, 9, and 10 have been used.
Use five female-to-female jumper leads to connect the Raspberry Pi GPIO pins to the
pins on the motor controller board.

GPIO pin connects to board pin


7 <–> In1
8 <–> In2
9 <–> In3
10 <–> In4
GND <–> GND
If your board does not have a GND pin, then strip the end of the female to female
wire and secure it into the GND terminal block that your battery pack feeds into.

You need to figure out which is your left motor and which is your right motor. You
also need to know which way they are driving to go forward, and which way they are
driving to go backwards.

Choose one of the motors. Use a marker pen to label it ‘right’ and draw an arrow on
it to indicate which way is forward.
Label the other motor ‘left’ and draw an arrow on it pointing in the same direction
as your first one.

Now open mu from the Raspberry Pi Programming menu.

Type the following to import the Robot class and create a Robot object. You can
name it anything you like. In this resource, the robot is called robby.

from gpiozero import Robot


robby = Robot(left=(7,8), right=(9,10))

Save you file and call it robby.py or something similar. You can then run it by
clicking Run.

Now open a python shell by clicking the terminal icon in the taskbar at the top of
the screen, then type ‘python’ and press Enter.
Now type the following to observe which way the motors turn.

robby.forward()
You can stop them by typing robot.stop().

Now, type the following command, and note which motor changes direction on the
second command.

robby.forward(0.4)
robby.right(0.4)
The 0.4 makes the motors go a little slower, so it is easy to see which way they
turn.

The motor that changed direction is the right-hand motor. If that was the one you
labeled ‘right’, then there’s nothing to change yet.
If it was the one you labeled ‘left’, you need to alter your Robot object in your
file to switch around the left and right pin numbers:

## e.g. change
robby = Robot(left=(7,8), right=(9,10))
## to
robby = Robot(left=(9,10), right=(7,8))
Now that you have the ‘left’ and ‘right’ sorted, you need to make sure you have
forward and backward set up correctly.

Again drive both motors forward.

robby.forward(0.4)
Check that both motors are turning in the direction shown in the diagram below.

If the right-hand motor is turning in the wrong direction, alter your robot object
by switching the order of the GPIO pin numbers. For instance:

## e.g. change
robby = Robot(left=(9,10), right=(7,8))
## to
robby = Robot(left=(9,10), right=(8,7))
If the left-hand motor is turning the wrong way, then do the same for its pin
numbers.

Assemble your robot

There is no “right” way to build your prototype robot chassis, but there are a few
things to bear in mind:

The chassis needs to house the Raspberry Pi, motor controller, and batteries.
The chassis needs to allow the mounting of a pair of wheels.
You may want to later add a couple of line sensors, and an ultrasonic distance
sensor or a lidar sensor to the chassis.
It’s always a good idea to build a prototype chassis first.

The first step is to place your motors into the chassis.

Place your motors inside the box, in roughly the position that you would like them
to sit.
Then use a pen to mark the place where the motors’ axle will need to pass through
the walls of the box.
Make sure you are giving your wheels enough room to spin around.
Eventually, you can learn how to laser-cut or 3D print a chassis, but in this
project, a cardboard box is used as a temporary solution.

Use a sharp object to poke holes through the sides of the box so that the motors’
axles can fit through.

You will need to fix the motors in place. Use an adhesive putty or tape to hold
them down.

Once the motors are in place, you can attach the wheels to the axles.

When the wheels are in place, you can screw a ball caster to the front of the
container to act as a third wheel.

If you’re using a power bank, you can now power up your Raspberry Pi.
If you want to make your own power bank, then follow the guide below.
5u892f8c

You might also like