Introduction: Balancing Robot / 3 Wheel Robot / STEM Robot

We have built a combined balancing and 3 wheel robot for educational use in schools and after school educational programs. The robot is based on an Arduino Uno, a custom shield (all construction details provided), a Li Ion battery pack (all construction details provided) or a 6xAA battery pack, a MPU 6050, a BLE Bluetooth module, an ultrasonic module (optional) and a servo to move an arm. There are also extensive education material available ready for use in class rooms.

The attached document is the instructions given to kids to build the robot in a series of steps which provide educational learning at each step.

There are 8 exercises which can be done before the full balancing / 3 wheel robot sketch is uploaded. Each of the exercises focus on a particular aspect of the robot, e.g. the accelerometer/gyroscope sensor, interacting with a smart phone app using Bluetooth, the ultrasonic sensor, the servo etc. The exercises are integrated into the physical construction of the robot, so when enough of the robot has been constructed to do an exercise, the sketch for the exercise can be uploaded and done. This helps to focus the fun of building the robot with educational learning.

It was decided to use an Arduino Uno because is it extremely common and used in many educational settings. We have also used, other than the shield, standard of-the-shelf modules which are readily available. The chassis is 3D printed and the design available on Tinkercad.

We have also found that this robot helps to inspire and provide confidence in kids to think about building their own creations and that it is not difficult to do so.

All the sketches are well commented and more advanced students can modify or write their own sketches. The robot can form a general platform for learning about the Arduino and electronics.

The robot also works with the "LOFI blocks" app, so kids can write there own code in a graphical environment similar to SCRATCH.

Note the above video above shows the mark 1 model, the robot now uses the RemoteXY Bluetooth app (which is available for both Android and Apple devices), the MPU 6050 is now located on the robot shield (not in the slider at the bottom of the robot - although you can still locate it there if you wish) and has an optional ultrasonic sensor which can be plugged into the shield.

Acknowledgements:

(1) pitch angle and PID control is based on software by Brokking: http://www.brokking.net/yabr_main.html

(2) RemoteXY app: http://remotexy.com/en/help/

(3) LOFI Blocks https://lofiblocks.com/en/ and LOFI Robot app http://www.eng.lofirobot.com/

(4) arms based on jjrobots: https://www.thingiverse.com/thing:2306541/files

(5) all sketches are stored on Arduino Create: https://create.arduino.cc/

(6) 3D designs are stored on TinkerCAD: https://www.tinkercad.com/#/

(7) the shield pcb design is available: PCBway Balancing Robot Shield - Share Project

Disclaimer: This material is provided as is, with no warranty of the correctness or otherwise of this material. Use of the 3rd party iPhone and Android apps named in this document is at the users own risk. The robot can use a Lithium Ion battery pack, use of the battery and power pack is at the users own risk. The authors assume no liability for losses suffered by any person or organisation using this material or from building or use of the robot.

Step 1: Parts List

To make the robot from scratch, there are many steps and it will take quite a lot of time and care. You will need a 3D printer, and be good at soldering and construction of electronic circuits.

The parts required to make the robot are:

(1) 3D print the chassis and caster wheel extension (see Robot chassis link relow)

(2) Arduino Uno

(3) Build the robot shield

(4) MPU 6050, AT9 BLE Bluetooth module, optional ultrasonic module (all plug into the shield)

(5) SG90 servo

(6) TT motors and wheels

(7) Build the power pack (either 6xAA battery pack or Li Ion battery pack)

The attached file explains how to obtain and build all the parts except the Li Ion power pack and the robot shield, which are covered in the next steps.

All the 3D printer parts are available in tinkercad (login to tinkercad and search for "balrobot" in the gallery):

Robot chassis: https://www.tinkercad.com/things/7kurIVi1mjH-robot...

Robot arms: https://www.tinkercad.com/things/3OeyaAKrnya-balancing-robot-arms

Robot faces: https://www.tinkercad.com/things/eSeVbkUcfF0-balan...

Robot heads: https://www.tinkercad.com/things/6SqwFytv6EO-balancing-robot-heads

additional arms pieces: https://www.tinkercad.com/things/dSYrW2rYkGl-balancing-robot-arms

Step 2: Robot Shield

The PCB design for the robot shield is done in Fritzing, attached is the Fritzing file if you wish to modify the design.

Also attached are the gerber files for the shield PCB, you can send these files to a PCB manufaturer for them to manufacture the shield.

For example, the following manufacturers can make 10 x PCB boards for around $5 + postage:

https://www.pcbway.com/

https://easyeda.com/order

The gerber files for the shield can be obtained here (note you need to create a login on pcbway to be able to download the gerber files):

https://www.pcbway.com/project/shareproject/Balancing_Robot_Shield_a6e0ec4c.html

Also attached is the make document for the shield.

Step 3: Power Pack

You can build either a 6xAA-battery pack or a Li Ion battery pack for the robot. The instructions for both are attached.

The AA-battery pack is much easier to construct. However the batteries only last approx 20/30 minutes before needing to be replaced. Also the servo cannot be used with the AA-battery pack so there is no moving arm.

The Li Ion battery pack can be recharged and lasts approx 60 plus minutes between recharges (depending on the capacity of the battery used). However, the Li Ion battery pack is more difficult to build and uses a Li Ion battery, Li Ion batteries needs to be handled with care.

The Li Ion battery pack includes a protection circuit, which protects the battery from over and under charge and limits the max current to 4 Amps. It also uses a Li Ion charging module.

You could use any Li Ion battery pack which has an output of approx 7.2 volts, but you would need to make up a cable with the appropriate robot shield plug.

Let me know if you have a good alternative power pack. The reason why I have made up this Li Ion pack is that it uses a single Li Ion cell which means it is relatively small and can be charged from any micro USB charger or from any USB port including a computer. Li Ion power packs I have seen around 7.2 volts use 2 cells and require a special charger, which increases the cost and isn't as convenient to charge.

If you choose to build the Li Ion battery pack (or use any Li Ion battery pack) you should be aware of the safety issues with such batteries, e.g. https://batteryuniversity.com/learn/archive/lithiu...

AA battery clip: https://www.tinkercad.com/things/iElP0AJXCNe-6xaa-battery-holder-clip

Power pack - wide tab: https://www.tinkercad.com/things/705WAtL3rYP-battery-pack-container-wide-tab

Power pack - narrow tab: https://www.tinkercad.com/things/hmmvN1lZneD-battery-pack-container-narrow-tab

Step 4: Robot Exercises and Sketchs

The full balancing robot sketch (it is Exercise 8 in the below list) is available here.

Once you have obtained all the parts, as you construct the robot you can do programming exercises along the way if you want to. These exercises along with explanations are available on Arduino Create – the links below take you to the Arduino Create exercises – you can then open and save the exercise in your Arduino Create login.

To upload sketches to the robot make sure your phone is not connected to the robot by Bluetooth - a Bluetooth connection prevents uploading occurring. Although generally not needed, the pin for the Bluetooth module is 123456.

All exercises which use Bluetooth (except LOFI Blocks) uses the "RemoteXY" smart phone app to control the robot. RemoteXY is available for both IOS (iPhone) and Android phones. See link for RemoteXY https://remotexy.com/en/ Both RemoteXY and LOFI Blocks apps are free.

The LOFI Blocks sketch uses the "LOFI Blocks" app https://lofiblocks.com/en/

When you load an exercise into Arduino Create, in addition to the arduino sketch, there are a number of other tabs which provide information about the exercise.

Exercise 1: Arduino Basics –blink the LEDs on the robot control shield red and green. You can do this exercise after Step (3) in the construction.

https://create.arduino.cc/editor/murcha/77bd0da8-1...

Exercise 2: Gyro Sensor – getting familiar with gryos and accelerometers. You can do this exercise after Step (4) in the construction. You need to use the “Serial Monitor”, with baud rate set to 115200.

https://create.arduino.cc/editor/murcha/46c50801-7...

Exercise 3: Bluetooth Link – establish a Bluetooth link, use a smart phone app to turn on and off the LEDs on the robot control shield. You can do this exercise after Step (5) in the construction. Connect using the RemoteXY app.

https://create.arduino.cc/editor/murcha/b29cfff6-a...

Exercise 4: Ultrasonic distance sensor (optional) – getting familiar with the ultrasonic sensor. You can do this exercise after Step (5) in the construction. You need to use the “Serial Monitor”, with baud rate set to 115200.

https://create.arduino.cc/editor/murcha/96e51fb2-6...

Exercise 5: Servo-mechanism – getting familiar with the servo mechanism and moving the arm, use a smart phone app to control the angle of the servo arm. You can do this exercise after Step (8) in the construction. Connect using the RemoteXY app. Note the Servo control uses digital pin D4.

https://create.arduino.cc/editor/murcha/6e492462-b...

Exercise 6: Drive motors – getting familiar with motors, run the drive motors forward and backwards. Needs the battery pack to be switched on. You need to use the “Serial Monitor”, with baud rate set to 115200.

https://create.arduino.cc/editor/murcha/617cf6fc-1...

Exercise 7: Basic Car – build a simple three wheel car (robot with 3rd wheel attachment), we use RemoteXY smart phone app to control the car. You can do this at the same point in the construction as above. Needs the battery to be switched on and insert the 3rd wheel attachment. Connect using the RemoteXY app.

https://create.arduino.cc/editor/murcha/beadea02-2...

Exercise 8: Full balancing robot – the code for the full balancing / three wheel robot. Use the smart phone app “RemoteXY” to control the robot.

https://create.arduino.cc/editor/murcha/c0c055b6-d...

Exercise 9: Line Tracing robot. It is possible to add two line tracing sensors, and use the ultrasonic plug to connect the line tracing sensors to the robot. Note, the sensors are connected to digital pins D2 and D8.

https://create.arduino.cc/editor/murcha/093021f1-1...

Exercise 10: Bluetooth Control. Using Bluetooth and a phone app (RemoteXY) to control the robot LEDs and the servo-mechanism. In this exercise students learn about Bluetooth, how to use a phone app to control real world things and learn about LEDs and servo-mechanisms.

https://create.arduino.cc/editor/murcha/c0d17e13-9...

Exercise 11: Hand following robot. This sketch uses the ultrasonic sensor to determine how far away your hand is from the robot sensor and the robot moves backwards or forwards to follow your hand position. You can connect via Bluetooth using RemoteXY to display the distance measurements from the ultrasonic sensor.

https://create.arduino.cc/editor/murcha/be21c181-a...

Exercise 12: Line Tracing with Colour Sensor Robot

This is a line tracing robot with a colour sensor to control the direction at an intersection. The colour sensor is a TCS34725 using I2C interface. The sketch has been designed to detect R, G, B colours.

https://create.arduino.cc/editor/murcha/00e91332-c...

LOFI Blocks Sketch – to use the "LOFI Blocks" app upload this sketch into the robot. You can then program the robot using the "LOFI Blocks" app which uses programming blocks similar to SCRATCH, see https://lofiblocks.com/en/ for details. The LOFI Block app is available for both IOS (iPhone) and Andriod phones.

https://create.arduino.cc/editor/murcha/b2e6d9ce-2...

Step 5: Balancing Robot Maths and Program Structure

The attached file gives an overview of the maths and software structure of the balancing part of the robot.

The maths behind the balancing robot is simpler and more interesting than you might think.

For the more advanced school students it is possible to link the balancing robot maths, to the mathematics and physics studies they are doing at high school.

In mathematics the robot can be used to show how trigometry, differentiation and integration are applied in the real world. The code shows how differentiation and integration are calculated numerically by computers, and we have found that students get a deeper understanding of these concepts.

In physcis the accelerometers and gyroscopes provide insight into the laws of motion, and a pratical understanding of things such as why accelerometer measurements are noisy and how to mitigate such real world limitations.

This understanding can lead onto further discussions for example, PID control and an intuative understanding of feedback control algorthms.

It is possible to incoroporate the building of this robot into the school curriculum, or in conjunction with an after school programme, from primary through to high school level students.

Step 6: Video Streaming Camera Accessory

We have created a raspberry PI based video camera which can be attached to the caster wheel extension to the robot. Is uses WiFi to transmitt the streaming video stream to a web browser.

It uses a separate power supply to the robot and is a standalone module.

The attached file provides the make details.

Raspberry PI Zero W camera mount: https://www.tinkercad.com/things/0Yxd4PHsSIg-raspberry-pi-zero-w-camera-mount

As an alternative, other standalone video streaming cameras such as the Quelima SQ13 could be attached to the caster wheel extension, e.g.: SQ13 SQ23 Mini Camera - AliExpress

Step 7: Using N20 Motors Instead of TT Motors

It is possible to use the N20 motor instead of the TT motor.

The robot runs smoother and goes much faster with the N20 motor.

The N20 motors I have used are 3V, 250rpm N20 motors, e.g.

https://www.aliexpress.com/item/N20-DC-GEAR-MOTOR-...

The N20 motors are not as robust and don't last as long, perhaps 5-10 hours of use.

The N20 motor requires you to 3D print the N20 motor mounts, and there is a wheel insert in enable a TT motor wheel to fit the axial shaft of the N20 motor.

The N20 motor mounts can be found by searching for "balrobot" in the tinkerCAD gallery (you need to login to tinkercad).

Robot N20 Motor mount: https://www.tinkercad.com/things/eGRM4byWTkv-n20-motor-mount

Step 8: Modify Robot for Line Tracing

To modify the 3 wheel extension piece for line tracing, attach two line tracing sensors as shown in the photo.

Remove the ultrasonic sensor and connect the line tracing sensors using the ultrasonic sensor socket.

Note, connect the two line tracing sensors data signal outputs (S pin) to Arduino pins D2 and D8 (the pins used by the ultrasonic sensor).

Up load the sketch Exercise 9: Line Tracing robot:

https://create.arduino.cc/editor/murcha/093021f1-1...

Note: to use sketch Exercise 12: Line Tracing with Colour Sensor Robot, the 3 wheel extension needs to be modified further by replacing the caster wheel by a small ball bearing wheel and clipping a special frame under the 3 wheel extension piece and attaching the line tracing sensors and colour sensor to this frame.

Robot line tracing color detector mount: https://www.tinkercad.com/things/8W41OFOT0N1-line-...