Thursday, 26 March 2015

Chicken Pi

Introducing Chicken Pi

Every Easter the school has an egg decorating competition. Last year the boys were victorious with a joint effort that used their soldering skills to create this great (and pun-tastic) scene.

The boys were really keen to use a Pi this year and inspired by the excellent egg-laying machine we saw at the Raspberry Pi birthday party, decided to build a Lego version.

We decided to use the Lego WeDo hub that we had to make fitting a motor easy, and then had the bright idea to use the distance sensor as the trigger: You put your finger in between the chicken's beak and on detecting the change in distance value reported by the sensor, the Pi activates the motor.  Manual re-loading of the egg is then required!

The eggs are inserted into a cage mechanism in the Chicken's body. The motor is mounted perpendicular to the cage and turns it via two a simple 90 degree gearbox. This rotates a central shaft that translates the egg around and over a hole in the bottom of the chicken.  A little trail and error enabled us to calculate how long to power the motor in order to achieve the desired range of motion.

The Pi is contained in a Smart Pi case, which has a number of Lego-compatible plates.

My favourite part of the model is the chicken feet, which you can see here next to the WeDo hub.

The control code was written by my son in Python and is really simple. It uses the excellent WeDo library.

from wedo import WeDo
import time 
wedo = WeDo() 
def turn(num,mote)
    wedo.motor_b = mote
    wedo.motor_b = 0 
while True:
    if wedo.distance < 7
All the entries were  displayed in a classroom. Because there might not be a mains socket within easy reach, the whole Chicken Pi was powered via an RS battery pack.

Here is a movie of it in action

By the end of the day, the battery pack was exhausted and one egg was completely destroyed (the other just about survived but had a number of serious cracks).  No prize this year unfortunately, but we were up against some tough competition: a solar egg-lipse themed display and the (genius) Egg Sheeran (an egg with a mop of ginger wool on top).

No comments:

Post a Comment