Archive for May, 2014

Lego WeDo with Debian Wheezy using scratch

Wednesday, May 14th, 2014

I bought a Lego WeDo set for my son, this set is composed by some lego technic pieces and a Hub with USB where you can connect a motor and two sensors, distance and tilt. This set works natively with Windows and OSX but not with Linux. The software includes gives you an educational graphical tool for programming based on scratch.

lego wedo debian

Scratch is a graphical programming tool for education designed by MIT, you can find more info on scratch website.
The software included with Lego is a more simplistic and easy for kids kind of scratch, It has less options, bigger buttons, and sounds that match the lego instruction designs, this software is not free, It cost 85€ and is sold separately from the inital box (WTF!). However It is possible to use original MIT scratch with Lego WeDo and Linux.
There are two versions of scratch, the 2.0 is web based and It doesn’t work with Lego and Linux, but the older on 1.4 works with Lego Wedo and It is included on Debian Wheezy.

Then you need only to install the package:

apt-get install scratch squeak-plugins-scratch

Then you can plug the Lego Hub on a USB port, and you can see It is detected:
[31412.408152] usb 3-3: new low-speed USB device number 2 using ohci_hcd
[31412.575322] usb 3-3: New USB device found, idVendor=0694, idProduct=0003
[31412.575333] usb 3-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[31412.575339] usb 3-3: Product: LEGO USB Hub V1.00
[31412.895290] generic-usb 0003:0694:0003.0001: hiddev0,hidraw0: USB HID v1.10 Device [LEGO USB Hub V1.00] on usb-0000:00:12.0-3/input0
[31412.895346] usbcore: registered new interface driver usbhid
[31412.895350] usbhid: USB HID core driver

But It doesn’t work, you need to add a udev rule, to do that create this file
/etc/udev/rules.d/99-wedo.rules with this content
ATTRS{idVendor}=="0694", ATTRS{idProduct}=="0003", SUBSYSTEMS=="usb", ACTION=="add", MODE="0666", GROUP="plugdev"

Then restart udev with
/etc/init.d/udev restart

Now everything is ready, start the scratch from Applications->Education-> Scratch.

Unhide the Lego Wedo options from the Edit Menu.
lego wedo debian

You will find new motion options

lego wedo debian

And on the sensors you have the Lego Wedo sensors tilt and distance.

lego wedo debian

In order to wait until a sensors detect a condition you can use this structure, a wait condition, an operator and a sensor box like this.

lego wedo debian

That’s all you have Lego Wedo using scratch. Enjoy!

Facebooktwitterredditpinterestlinkedinmail