Using Catroid to Command a Servo Position or Turn a DC Motor

My passion is robotics and computer vision. However, since becoming a father 12 years ago, getting kids excited about robotics has also become one of my passions. I discovered Catroid while searching for a programming language for my youngest son, who will be turning 8 this fall, to use on his Nexus 7. It's amazing how quickly kids ramp-up to the concept of using graphic blocks to create something (he is also a big Minecraft fan). He has my passion for robotics, so it was not too long that he started asking about using Catroid to control his robot. After researching smartphone to servo or DC motor interfaces, I discovered there were not a lot of options available. Either the solution only worked with the latest smartphones, or the solution worked with Android only. In addition, all the solutions required custom software. There were no simple methods of interfacing hardware to both Android and iOS smartphones that were compatible with many application in the iTunes or Google Play markets.

This lead to the development of the EMGRobotics line of Audio Interface boards. I decided early on that these boards would plug into the headphone jack since they all  have headphone jacks. In addition, I determined that the boards should be controllable by WAV files due to almost all of the smartphone programming applications support WAV file playback, including Catroid. All you need to do is simply download the WAV files from and play them using Catroid sound blocks.

STEMbot1 - You can see more pictures in the Instructable here.

Playing back the WAV file sends a specific command to the A2SCB servo controller, sending both servos to the positions encoded in the WAV file. When using continuous rotation servos (see STEMbot1 instructable for more information) the servo internally converts the position command into a direction and speed command. Inserting a "wait" block after the "start sound" block controls how long the servo turns in the specified direction and speed.

The following Catroid code causes the robot to drive in a square while showing a picture of my son.

The "Start sound" block commands the continuous rotation servos on STEMbot1 to start a slow rotation that will result in the robot moving forward. The "Wait" block specifies how long the robot travels forward, in this case five seconds. 


The screenshot above shows the turn portion of the program. The "Start sound" block is used to send the slowright.wav sound out the headphone jack to the A2SCB_ML. The A2SCB_ML converts the sound pattern into servo commands that will result in STEMbot1 turning. The "Wait" block determines how long STEMbot1 turns. The wait times are determined by trial and error.


When the code runs, the robot drives in a square pattern while displaying a picture of my son.

The above Catroid program is designed to run on the STEMbot1 robot. STEMbot1 is a simple two wheel robot that uses two RC servos as drive motors. The RC servos plug into an A2SCB_ML servo controller from The A2SCB_ML plugs into the headphone jack of the Android phone running Catroid. STEMbot1 can be built in less than an hour and requires no soldering. You can find the instructions for building STEMbot1 on the Instructables website here.

The above Catroid program is very simple and only demonstrates only a small portion of what Catroid can do. Catroid also supports some of the sensors available in modern smartphones including: the 3-axis accelerometer, the magnetic compass, and the gyroscope. My son and I are still learning how to use these in our Catroid programs.

You can install Catroid on your device by viewing this website on your Android phone and clicking here: catroid-0.7.3beta-1644-debug.apk

For more information:


EMGRobotics A2SCB_ML servo controller:

Views: 524

Comment by eric gregori on June 21, 2013 at 10:49am


You need to be a member of buildsmartrobots to add comments!


© 2017   Created by eric gregori.   Powered by

Badges  |  Report an Issue  |  Terms of Service