Halloween Pumpkin with Servo Controlled Eyes


It’s Halloween 2017 and I decided to create a pumpkin with moving eyes. The result is a pumpkin with three ping pong ball eyes hooked up to some small servos and controlled with a Raspberry Pi and an I2C control board.

Here is a short Instagram video of the eyes in action :

The ping pong balls are pivoted in a ring with a small arm glued on the back. This arm is connected to a small servo by some paper-clip wire. I 3D printed some custom parts to connect this all together. It worked fine but the hard bit was holding these three eye units in place. Eventually I used wooden cocktail sticks which you can see in this Instagram video :


The servos were then connected to an I2C servo control board which can support 16 servos. This board is then connected to a Raspberry Pi running a basic Python script.

3 Eyed Pi Powered Pumpkin

The Pi and control board were powered from a USB power bank with twin USB sockets. The controller board takes 3.3V from the Pi to deal with the I2C logic and a separate 5V feed from the battery to provide power to the servos. Everything was thrown in a plastic food bag to stop it getting wet.

The Python script uses the excellent Adafruit 16-channel servo driver library which is explained here : https://learn.adafruit.com/16-channel-pwm-servo-driver/using-the-adafruit-library

This library is compatible with other 16-channel servo boards that use the PCA9685 chip.

For simplicity and speed I drew on the pupils with a Sharpie once I had the basics working.

3 Eyed Pi Powered PumpkinThe script randomly selects an eye and moves it to a random position between its maximum and minimum. It then waits a randomly determined time before choosing another eye to move. Using cron I set the script to run when the Pi boots.

I will add a few more details and photos when I disassemble the pumpkin. I was in a bit of a rush and didn’t have time to take photos of the 3D printed eye brackets or take a copy of the Python script.

Parts Used:

  • Ping pong balls
  • 3 sets of custom 3D printed brackets
  • 3 “9g” equivalent micro servos
  • 16-channel I2C servo control board [Adafruit]
  • Raspberry Pi
  • USB power bank
  • Female-female DuPont cables to connect control board to Pi’s GPIO pins
  • USB to male DuPoint cable to connect power bank to control board screw terminals

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.