Using the Rasp Pi to make Halloween really spooky

Lead Image © Martin Malchev, 123RF.com

Trick or Treat

You can give digital support to some pretty scary special effects for your next Halloween using the Raspberry Pi.

Trick or Treating on All Hallows Eve has spread as a custom practiced by many children across the world. The practice originated in Ireland and crossed the ocean with immigrants arriving in the US. Now, Raspberry Pi (Rasp Pi) users have an opportunity to bring Halloween into the cyber age with a digital ghost that moans, shrieks, blinks its eyes, and waves its arms.

Eyes and Mouth

For the eyes and the mouth, I suggest a ready-made LED module that consists of the MAX7219 and an LED matrix with 8x8 diodes. You can purchase this component from numerous sources [1]. Because deliveries from China can occasionally take up to four weeks, a domestic source might be the best option.

The module has an Serial Peripheral Interface (SPI), which is all you need to connect this component to a Rasp Pi. For more information on SPI, see the "SPI" box. The circuit diagram in Figure 1 shows how to connect the modules. You can also find this diagram on the FTP site in gEDA and EPS formats [2]. A regular, commercially available grid board can be used to give the module a solid mounting foundation.

SPI

SPI was developed in a Motorola laboratory for the purpose of connecting different peripheral components, known as slaves, to a bus master. Communication occurs serially and synchronously. This means that the bus master determines the clock rate for data transfer over the CLK line. In addition to this line, two other lines are used for data transfers: the MOSI ("Master Out, Slave In") line and the MISO ("Master In, Slave Out") line.

The devices participating in the communication do not have a fixed address. Rather, they simply transfer the data to the next slave. In a sense, the SPI bus functions like a very long shift register. The CE (Chip Enable) line allows the slaves to determine whether the state of the shift register is consistent. As soon as the master has shifted all the data to the appropriate slaves, it raises a signal, which allows the slaves to carry out their read or write operations.

For this process to work smoothly, the bus master has to know the entire bus topology. Data from the last participant wanders through all of the other participants on the bus. The slaves usually have a NOOP (No Operation) function that tells them to ignore the data for processing.

To use the SPI bus, you need to adapt the control software precisely for the hardware, which requires you to read through the data sheets carefully for individual devices hanging off the bus. The SPI bus is often used for displays because they usually include large amounts of data in one chunk. In contrast, the Inter-Integrated Circuit (I2C) bus offers numerous advantages in situations involving many individual read and write operations for a variety of I/O components.

Figure 1: The circuit diagram for the Halloween ghost. If you have problems with 1Kohm resistors in series, try using 220-ohm resistors.

Figure 2 shows how the face of the ghost looks behind the scenes. If the modules come equipped with curled pin connectors, you should exchange these for straight connectors. They are used to connect the module above the header [3] on the board. With this placement, you have the option of recycling the module for later projects.

Figure 2: The face of the ghost. Here you can see how the LED modules are placed on the board.

The Arms

Two small servomotors cause the arms to move. The arms themselves consist of simple tension wire that would ordinarily be used for fences. Figure 3 shows that the hands are made of latex gloves like those used in a medical setting. One sticky point in the truest sense of the word was to figure out how to fasten the servomotors. The arms work like a long lever, so it was important to find a stable fastening mechanism and connection.

Figure 3: The construction for the arms of the ghost together with the servomotors and latex glove hands.

If you do not have a power supply with the correct voltage for the servomotors, then an AC/DC converter [4] can help move things along. Servomotors are known to create frequent interruptions in the power supply, so it is a good idea to run an extra one. The lines for the signals to the servomotors can be separated galvanically via an optical coupler to prevent disruptions from reaching the Rasp Pi. Avoid connecting the wires to ground to ensure galvanic separation. You can view both optical couplers in the lower part of the wiring diagram (Figure 1).

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content