Our Robotic Project

For our Year 10 Computer Programming project at our school we were given the chance to work with Arduino microcontrollers.

My project partner Lachlan and I decided to make a remote controlled DC motor robot.

The components that we used were the Arduino board, the Ardafruit Motorshield, a Freetronics Bluetooth shield, and two 9V Lego motors.

There was no instruction manual for this, so we had to find all of the code to make this work from the internet. The code was not in one single place, so we needed to put different parts of code together to make this work.

We built a small vehicle using Lego blocks and started to play around with the basic Ardafruit Motorshield code to see what we could get it to do.

It was easy to get it to go forward and back, but getting it to go left and right was a bit more difficult. Working out how to power the board and shield off one battery was also tricky until we discovered that we could use the ‘Vin’ jumper on the motor shield.

Our teacher Mr Vinton was also a member of our team and helped us by providing all of the resources and by printing off all of the code and asking us if we knew what each part did and how we thought it might go together.

Setting up the Bluetooth was the trickiest because our school’s Windows 7/8 computers didn’t enable Bluetooth serial ports. With a lot of trial and error we finally got it to work by using a Windows 8 laptop (standard operating system).

We used the Orionrobots Processing code to drive the robot from a PC and we used Bluetooth Controller to drive it from an Android tablet

The code that we used is below:

The Adafruit MotorShield code from ArdaFruit:

To communicate via the serial port to the bluetooth shield we used this code from © 2015 OrionRobots and we changed it to suit the Ardafruit MotorShield. Below is the original code:

At the top of the code we also included the standard code for communication to the serial port via BlueTooth

And we defined the key commands with code manipulated from © 2015 OrionRobots

To communicate with the serial port on the computer which was used to key the commands to the Arduino robot we used the ‘Processing’ code from © 2015 OrionRobots

Our finished Arduino code for our BlueTooth controlled Ardafruit MotorShield Arduino robot looked like this:

The ‘header’ section of code:

The ‘setup’ section of the code uses the Ardafruit MotorShield code parts, but we needed to do quite a bit of tweaking to get it right.

You will need to make sure that your motor connections are the right way around to get the motors running the right directions (this needs trial and error testing).

The ‘loop’ section of the code was manipulated from the original Orionrobots code

Our robot code can be found here: https://github.com/Seven7au/arduino_robot_code

And the video of the robot in action can be found here: https://www.youtube.com/watch?v=abo6qfq2r4U

The original Orion Robot code can be found here:

All the code – for each of the stages, and the final stage of this tutorial can be viewed at Github | dannystaple | orion-explorer-arrow-control.

The Ardafruit tutorial PDF for the Ardafruit MotorShield V2 can be found here: https://learn.adafruit.com/downloads/pdf/adafruit-motor-shield-v2-for-arduino.pdf

Documentation on how to set attach the Freetronics BlueTooth shield to your computer so that you can communicate via ‘serial over BlueTooth’ can be found here: http://www.freetronics.com.au/pages/bluetooth-shield-quickstart-guide#.VXOQSs-qqko


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s