Arduino Robotic Controller Software Update

The RobotFreedom robots are controlled by two code bases. The first runs on a RaspberryPi and is written in Python. You can read more about it here. The second code base controls the movements and lights on the robot. It is written in C and runs on a Arduino. This article will get you started on developing with that code base. You can download it GitHub.

Please note, this material is provided for informational purposes only and is not a guide on how to create the designs. Please take a look at our disclaimer.

The movement controller is designed to be light and simple compared to the main AI code-base and is ideal for a beginner. The focus is to provide an interface for a human or AI to control a robot’s moving components (arms, legs and wheels). We use a Arduino Mega Board because it has a plenty of digital pin to attach our components to. Below is an image of a Arduino Mega board.

Arduino’s can be controlled via serial communication through a USB port or you can code it to run independently. Our robotic walkers are controlled only by an Arduino. This project is intended to be controlled by an AI installed on a RaspberryPi.

The purpose of the program is to receive incoming messages and perform the requested action. For example ‘a’ means raise the left arm. When the program receives an ‘a’ command it sends a command to a H-Bridge which then send power to a linear actuator to raises the left arm.

To start, install the Arduino IDE on your preferred development OS. Linux, OXS and Windows is supported. You can get the code here.

Next, download the required library and copy them to your development folder.

Adafruit_BusIO
Adafruit_I2CDevice
Adafruit-GFX-Library
FastLED

Launch the Arduino IDE and from the menu bar select:
Sketch>Include Library>Add Zip Library…

Launch the Arduino IDE and from the menu bar select:
Sketch>Include Library>Add Zip Library…

Then point to one of the zip files you have downloaded. Repeat for each required library.

To open the project, double click on the movement_controller.ino file and the Arduino IDE should automatically launch. If it does not launch you can load the sketch by selecting File>Open then navigate to your project file.
Now choose a board type. When you connect your Arduino board it should be auto-detected by the IDE. For some brands you may have to manual select it from the combo box. For off-brand Arduino we recommend searching forums for the best match. Many specify incorrect boards in their descriptions.

Next select >Sketch>Verify Compile. At the bottom of the IDE a console will appear and provide a detailed log. If you missed any libraries you will receive an error message. Loading any required libraries and try again.

Once the code is compiled select sketch>upload to deploy your code.

Below is a list of the components the code can control:

H-Bridge
FastLED
Linear Actuator

The image below is the wiring for the Arduino:

To test select Tools>Serial Monitor from the main menu. At the bottom of the IDE a new tab titled “Serial Monitor” will appear. From this console you can directly communicate with the Arduino.

 In the console window type “5”. You should see a response from the Arduino in the console and if the LED is connected to the Arduino it should turn white and flash in a circular pattern.

Now you can control your own robot!
Happy Creating!