After some initial fun with Lego WeDo and Scratch, our enthusiasm waned, mainly due to the necessity to tether any model to our computer. Somehow it didn't seem quite so exciting as Lego Mindstorms where the microcontroller is part of your model giving it the freedom to roam.
Inspired by this Lego / Raspberry Pi model built by another geeky parent I decided to see if we could do something similar. As we already had a WeDo hub, it seemed that would be simpler than getting involved with all that fiddly looking GPIO stuff.
First, the 'car'.
Lego WeDo + Raspberry Pi |
Pretty neat eh? The WeDo hub is sitting under the RPi. The black box at the back is not functional; it houses a ridiculously long USB cable which is the only one I have with a slim enough micro USB connector to fit in the PiBow case (my only gripe with this case - others have the same problem). The ribbon cable is not in use.
It was inspired by:
Lego 9719 Robotics Invention System |
The Pi itself is housed in a PiBow which is a great case and has the added advantage of a few holes in the bottom which fit perfectly onto Lego bricks. The power source is a Powergen battery pack (as used by 'Geek Dad').
Feeling pleased with myself I knocked together the software. At the time, Scratch only officially supported a single motor, so I decided it was time for my son and me to move onto Python. This was already installed on our Raspberry Pi, but we needed some extra stuff to get it to work with the WeDo hub.
After a few teething problems I managed to install this on our Raspberry Pi. But then we ran into other problems.
First, there are only two USB ports on our RPi. Ideally we needed ports for all of the following:
- wifi adapter - to login remotely
- bluetooth adapter - we planned to use the Wii Remote as a controller
- Lego WeDo hub
I plugged in an unpowered USB hub hoping that would solve the problem. It didn't. Some things didn't work at all, and others were intermittent. Plus, the hub was an added weight for the 'car' to be carrying around.
So, we ditched the Wii Remote idea.
After booting up the RPi I connected to it remotely over the wifi using Putty from my laptop (I had already noted its IP address from an earlier session). Then I ran the python script remotely. Controlling the car was with a simple character entry interface via Putty. And here we see it in action:
Successfully controlled, but rather slow. The hub can only deliver 5V as opposed to the 9V required by the motors. In addition, even under quite small loads (a ruck in the carpet for instance) the motors sometimes would just stop. The only way to recover was to unplug the Lego WeDo hub, put it back in and restart everything. Not the experience we were hoping for.
I have since tested the Lego WeDo hub on different computers both with Python and Scratch. Whenever two motors are connected it is very easy to stop them functioning by putting them under quite small loads. This has never happened with just one motor attached. I've not seen any reports of this elsewhere, but then not many people are using two motors with it. Perhaps I just have a faulty hub?
Sadly, it is farewell to the simplicity of the Lego WeDo hub for us. Next step is to get to grips with the GPIO pins on the RPi and to get some real power to our motors!