Third party cookies may be stored when visiting this site. Please see the cookie information.

PenguinTutor YouTube Channel

Computer controlled school project - bee

This is the first Raspberry Pi based project that I have done with my children. This is my son's school project which was opened up as a family project. My son (age 5) made the bee model, the bee hive and the flower and my daughter (age 7) was responsible for the programming. I helped out with some of the soldering and with the research into getting Scratch to talk to the Raspberry Pi GPIO ports.

Bee project with Raspberry Pi

See the YouTube video for a quick demonstration. Raspberry Pi bee project.

How it works

Bee project with Raspberry Pi - internal electronics and wiring
The project is based around a low cost Raspberry Pi educational computer. There are two models of the Raspberry Pi and whilst either will work the model A has been used for this project; which is cheaper than the model B, and has a lower power requirement. The Raspberry Pi is powered by 4 x D-Cell rechargeable batteries connected through an on/off switch to the GPIO connector.

The location of the bee is determined using two reed switches and a magnet inside a bee made out of air clay. The reed switches and two LEDs are connected using appropriate resistors to the Raspberry Pi GPIO using a Slice of Pi expansion board.

The reed switches connect from pin 7 (flower reed switch) and pin 19 (hive reed switch) to ground. The LEDs are connected to pin 11 (bee hive LED) and pin 12 (flower LED).

My 5 year old son made most of the model and even helped a little with the soldering of the LEDs, but I did the soldering on to the Slice of Pi.

Programming

The programming was done by my 7 year old daughter. I've recently been teaching her Scratch programming using the Raspberry Pi educational manual and this is her first software project. I did the research on getting Scratch to talk to the GPIO (details in a future post), but she created most of the rest of the code on her own. There is one anomoly (feature/bug?) in that image on the screen changes as soon as the bee is moved away whereas the LED and bee sounds change only after the sound has finished playing, but that would have been quite difficult to explain and fix, so has not been tackled.

The source code is shown below:
Sprite script for Scratch Raspberry Pi projectBackground script for Scratch Raspberry Pi project

There was some additional setup necessary; in particular a Python GPIO library is required so that Scratch can communicate with the Raspberry Pi GPIO ports and some changes are needed to Scratch to remove a pop-up message.

Details of the configuration changes required are in a corresponding blog entry: Running Scratch program - auto full screen (presentation mode) with Raspberry Pi GPIO.

Cost

This was relatively inexpensive considering it is an interactive project and includes the cost of a dedicated computer. The two main costs were the Raspberry Pi (which can be reused in other projects) and the rechargeable batteries (which cost about the same as the Raspberry Pi). The speaker used is a MP3 player speaker which was quite expensive, but it should be possible to get a low cost unpowered speaker from a discount shop or by wiring your own from standard components. The list below shows approximate costs and suppliers:

  • Raspberry Pi Model A - Farnell / RS - £20
  • Batteries (rechargeable NiMh) - Maplin - £20
  • Battery holder switch and wires - Maplin - £5
  • Reed switches - Maplin - £5
  • LEDs - Maplin - £1
  • Slice of Pi - ModMyPi - £5
  • 2GB SD card - Various - £5
  • Speaker (cheaper options available) - Argos - £10
  • Air drying clay - WH Smiths - £6
  • Enclosure - scrap box file - Free
  • Magnet - unknown already had

Also used are a keyboard and mouse (existing ones used for PC) and optional monitor with appropriate cable (eg. DVI / HDMI to vga convertor).

Summary

This was a fun project involving the whole family. We learned about bees as well as programming and some electronics in showing a practical use for reed switches. My daughter is already trying to think up some other projects she can do herself as she really enjoyed helping her brother with his project.

More information about the Raspberry Pi

See the guides and blog posts relating to the Raspberry Pi.

Previous Disco lights
Disco lights
Next Home automation - RasPi
Home automation - RasPi