Introduction: Fun Pi's Raspberry Pi 3 Tank

We are going to create a tank that will be controlled by the Raspberry Pi and a WiiMote. Don't worry, we will go into details in the following steps. This project will promote many aspects of the STEM (Science, Technology, Engineering and Math) curriculum!

Step 1: Welcome! the Raspberry Pi Tank!

Step 2: Parts List

Raspberry Pi 3

Power Cable

3.1 Battery pack

Tamiya double gearbox

Tamiya tank treadset

Ln298n motor controller

Voltage Controller

Micro SD Card 8GB

Jumper wires

Acrylic 12in x 12in

Zip ties (200 count)


Machine Screw: 2 inch #6-32Machine Nuts #6-32

Alligator Clip to USB

Wiimote Controller Generic

Step 3: Base Plate

We used Coral Draw and a laser cutter to create all of the plates. Minimum you need two plates, a base plate to hold the motors and tracks, and the top plate to hold the Pi and the batteries.

If there is no access to a laser cutter you can order the Tamiya base plate that is designed for the tank tracks.

There are files for Coral draw, AutoCAD and a PDF of the file we used for the plates.

Step 4: Building the Motors

We used the Tamiya dual motor to move the Tank. The reason we picked the dual motors is to control both sets of tracks individually so the tank will be able to turn and spin.

First we must cut all of the pieces.

Follow the directions that came with the motors. There are multiple gear ratios to choose from. We chose the second lowest gear ratio. This gives enough power to the treads so we can actually move the tank. We tried a higher gear ratio but the tank would not move due to not enough torque from the motors.

Step 5: Connect Motor and Tracks to Base Plate

Once the motor is complete you can attach it to the base plate.

After the motor is in place you can start building the tank tracks and attaching those to the base plate and motor.

Attach the wires to the motors, keep the positive and negatives in the same location on both. Make sure you have a good connection so the wires do not come off the motors.

Step 6: Wiring Diagram

This is the basic wiring diagram for what we need to control the tank.

We had to use the 4 AA battery power in the diagram because we could not find a USB power supply in the program we used. Technically you could use the AA batteries but the batteries would die quickly and are not rechargeable.

Step 7: Motor Controller

We used the Ln298n motor controller to power the motors and to send power from the Raspberry Pi to the motors allowing the tank to move.

Step 8: Digital Boost Voltage Converter

To give enough power from the usb power supply you need to use a Digital Boost Voltage Converter to regulate the power to have enough power to control the motors. The converter we used has an LED display to show how much voltage you are using. This makes changing the voltages a lot easier than using a multi-meter to read the voltages.

Step 9: ​How to Wire the Robot

The easiest way to wire the tank is to start at the bottom. Follow the diagram to know where to connect the wires.


The positive and negatives on the motors must match each other. You must use a male jumper wire on one side of the wire, and a stripped wire on the other side to connect to the motors.

Motor controller:

Connect the positive and negatives from both motors into Output A and Output B Use a positive and negative, male to male jumper wire to the Driver Power Input and the ground input Cut the end off a female to stripped wire. Connect the stripped end to the ground input and the female to the GPIO pin ground #6 There are 4 Female to female jumper wires that need to be plugged into the Control Inputs of the motor controller

Voltage regulator:

The IN- side will need a stripped positive and negative on one side and a usb port on the other. The OUT- will take the positive and negative wires that were plugged into the Driver Power input and the ground.

Raspberry Pi GPIO pins:

IN1 and IN2 on the motor controller. IN1 will go in pin 11 and IN2 will go in pin 12. (GPIO17 and GPIO18)

IN3 and IN4 on the motor controller will go in pin 15 and 16. (GPIO22 and GPIO23)

Wire Colors to use:

Red - Positive

Black - Negative

Brown - pin 11/IN1

Orange - pin 12/IN2

Yellow - pin 15/IN3

Green - pin 16/IN4

Step 10: Raspberry Pi 3

First you must setup the Raspian OS on the Pi to have an easy to use interface that anyone can use.

Install Raspian OS

Insert SD card into a SD card reader and check which drive the SD card is assigned.

Start Menu

- My Computer (This PC) In “Under Devices and drives” you SD card will appear with a drive letter You now must write the Raspian OS to the SD card using a program called “Win32DiskImager”

Once Downloaded, Run “Win32DiskImager” as an Administrator.

Right Click the .exe file and run click “Run as Administrator.”

Once opened select the Image of Raspian that you downloaded earlier.

Select the drive letter that you found in Step 1b. Click Write button Eject SD card, You can now install Raspian on your Rasberry Pi

The easiest way to install raspian on the Raspberry Pi is to use the program “NOOBS” (New Out of Box Software) This will give you very user friendly install screen when you turn on the Pi.

Once you have Raspian downloaded on your Pi you can either use the Python IDE or the terminal to create the programs.

nano python *filename*.py

Copy code bellow:

To run the program type sudo python *filename*.py

Step 11: WiiMote

To control the robot using a WiiMote you must use Python code to control the GPIO pins on the Raspberry Pi.

1. Install the WiiMote library using the Terminal with the code bellow:

sudo apt-get install python-cwiid

To install the robot controls copy the code bellow:

#based on Matt Hawkins' code

#Re written by Fun Pi's

import cwiid import time import RPi.GPIO as io

io.setmode(io.BCM) #Motor 1 is designed to be the motors on the left, Motor 2 is designed to be on the right #If one motor is in the wrong direction you can swap the pins around to save you having to re-wrire the robot. m1a = 17 #Motor 1 Forwards m1b = 18 #Motor 1 Backwards m2a = 22 #Motor 2 Forwards m2b = 23 #Motor 2 Backwards pins = (m1a,m1b,m2a,m2b) for i in pins: io.setup(i,io.OUT)

for i in pins: io.output(i,False)

button_delay = 0.1

print 'Press 1 + 2 on your Wii Remote now ...' time.sleep(1)

# Try to connect to the Wiimote & quit if not found try: wii=cwiid.Wiimote() except RuntimeError: print "Can't connect to Wiimote" quit()

print 'Wiimote connected' wii.rpt_mode = cwiid.RPT_BTN while True: buttons = wii.state['buttons'] if (buttons & cwiid.BTN_UP): #Forwards time.sleep(button_delay) io.output(m1a, True) io.output(m2a, True) elif (buttons & cwiid.BTN_DOWN): time.sleep(button_delay) io.output(m1b, True) io.output(m2b, True) elif (buttons & cwiid.BTN_LEFT): time.sleep(button_delay) io.output(m1a, True) io.output(m2b, True) elif(buttons & cwiid.BTN_RIGHT): time.sleep(button_delay) io.output(m1b, True) io.output(m2a, True) else: io.output(m1a, False) io.output(m1b, False) io.output(m2a, False) io.output(m2b, False)

#press button A to stop all motors if (buttons & cwiid.BTN_A): time.sleep(button_delay) for i in pins: io.output(i, False)

Step 12: Finished Product!


seamster made it!(author)2016-05-04

Very nicely done, this looks like a fun little tank!

ducky1337 made it!(author)2016-05-10

Thank you! I am still in the process of fine tuning the Instructable but have been busy with work and school. Please check back later and it will be completed with a lot more information about how to build this project!

About This Instructable




More by ducky1337:Fun Pi's Raspberry Pi 3 Tank
Add instructable to: