PYTHON
Build a Pi-powered helicopter diorama
Sean Conway uses a helicopter model to demonstrate how lighting, sound and motion can be accomplished using a Raspberry Pi.
Sean D. Conway
OUR EXPERT
Sean D. Conway as a former IT security specialist turned retired guy. He enjoys creating Raspberry Pi projects for model railroad sets.
This tutorial takes us behind the scenes of a Raspberry Pi-powered diorama to explore the concept of concurrency. A diorama is a three-dimensional full-size or miniature model. For this exercise the diorama is a miniature helicopter complete with lighting sequence, engine run-up sounds, and blade motion. We’ll be using the computer power of the Pi to generate light, sound and motion animation to bring the model to life.
The animation of light, sound and motion are added to the diorama through electronics attached to the Raspberry Pi general-purpose input and output (GPIO) pins. Four sets of LEDs provide cabin, strobe, navigation and landing lighting. The mp3 sounds of a turbine engine spooling up and whirring are generated to the Pi’s headphone jack. Finally, a stepper motor gradually speeds up to provide rotor action. The final product is a digital orchestra conducted by the Pi using Python code.
We’ll assume that you have a basic understanding of the Raspberry Pi, including loading the operating system and installing software. A familiarity with using the command line interface (CLI) is recommended to explore the workings of the Python program.
Concurrency
Key to this project’s design is concurrency, which means at the same time. While consecutive means one after the other in a series. It’s no surprise that criminals convicted of multiple crimes would prefer to serve concurrent terms as a sentence, instead of consecutive terms.
The Pi in the helicopter diorama mixes both the concurrent and the consecutive operation of the lights, sound and motion to produce the animation. In the Gantt chart (facing page) there are three colours corresponding to the three types of animation.
There are four sets of LEDs (the lights), coloured different shades of yellow that need to be activated consecutively over time. The cabin lights first come on, then the strobe lights flash. Finally the navigation lights and landing lights are activated in sequence. A delay between the lighting of each is added to draw the viewer’s attention to the change in the scene.
When the light sequence activation is complete, the Pi runs the sound process (coloured blue). The sound mp3 file contains the audio for the start, run-up and shutdown of the helicopter engine. While the lights are activated and sound is produced, a motor (coloured green), is activated through a sequence of speeds to physically turn the rotor blade from slow speed through medium then fast and back to slow speed over the time period.