2013-03-30

Python support for the Lego WeDo kit

I started playing with my son on his Lego WeDo kit using the Scratch language on his Rasberry pi.

It felt a little bit limited on that and found some basic python code on github from Ian Daniher to drive it.

and, I could not help it ... I debugged it, pythonized it, documented it and published it properly on Pypi !

To install it:
pip install wedo
To initialize it if you have a single device:
>>> from wedo import WeDo
>>> wd = WeDo()
Activating the first motor full forward:
>>> wd.motor_a = 100

Activating the second motor half speed/force backward:
>>> wd.motor_b = -50

Current value of the tilt sensor, you can find the matching constants FLAT, TILT_BACK, TILT_FORWARD, TILT_LEFT, TILT_RIGHT in the wedo package:
>>> wd.tilt
3

Current distance value in meters of the distance sensor:
>>> wd.distance
0.21

Feel free to contribute to the project on github. Enjoy !