Tuesday, May 31, 2016

Driving Adafruit motor shield from RPi with Python

As I planned to build a RPi controlled robot, I selected the Adafruit motor shield v1 as the component to control the robot's two DC motors. But given the project I was using as a guideline uses a L293D-based circuit and all the source code is Python, I was facing a problem...
However, as Google is (most of the time) my friend, I was able to pick some helpful hints. On one side, driving an Adafruit (Arduino) motor shield from a RPi had been fortunately attempted before so the wiring and most of directions were there, although the source code to run in the RPi was C based. This subtle difference posed me with the task of translating from C to Python, something I had never done so far (my Python knowledge is quite basic).
The experiment proved successful and I ended up with a Python module that replaced the original one used to drive the motors.
As future improvements to this module, I expect to be able to control two servos from Python as well. Stay tuned to know more about it!

No comments:

Post a Comment