Writing own Code for DiddyBorg V2


I have built and setup my DiddyBorg v2 and all of the example programs work fine, however when I write my own code in python, and run simple functions, I am getting 'Failed sending motors off command!', etc. Could someone shed some light on this issue please as I am using this as part of my A-Level coursework! I feel as though this is something to do with the fact that I am writing .py files, and executing them using sudo python filename.py in the terminal, as using IDLE throws up completely different errors.



piborg's picture

It might be hard to figure this out without seeing your code, but if I had to guess my first thought is that you have missed out the TB.Init() call before trying to set motor speeds.

This is a stripped down example which should do the minimum needed to setup the ThunderBorg and then command the motors to stop:

# Setup the library ready for use
import ThunderBorg                      # Load the library
TB = ThunderBorg.ThunderBorg()          # Create a board object
TB.Init()                               # Setup the board

# Now the motors should be controllable

Works perfectly now - silly me! Thanks for the super-quick help!

Out of interest, is running the code in Python 3 IDLE a no-go?


piborg's picture

IDLE should be fine, however the standard ThunderBorg.py script only works with Python 2.

You can get a Python 3 compatible version from this post: ThunderBorg script for Python 3.

Subscribe to Comments for "Writing own Code for DiddyBorg V2"