GB
  
You are currently viewing the United Kingdom version of the site.
Would you like to switch to your local site?
14 MIN READ TIME

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.

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.

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99p
SUBSCRIBE NOW
30 day trial, then just £9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
March 2021
VIEW IN STORE

Other Articles in this Issue


WELCOME
Orchestral Manoeuvres in the Docker
Jonni’s been arguing with me this issue –
REGULARS AT A GLANCE
Is online privacy the hot topic for 2021?
PRIVACY
Linus vs Intel
Linus Torvalds blasts Intel for not supporting ECC memory
Affordable RISC-V PC arrives
BeagleV is a RISC-V computer designed to run Linux
THE END IS NIGH, SO…?
Matt Yonkovit is Percona’s Chief Experience Officer and
SPRING CLEANING
Keith Edmunds is MD of Tiger Computing Ltd,
Apple M1 Macs get Linux support
Apple’s OS 11.2 now supports booting custom kernels
FOSS watch
PineTime takes on the Apple Watch and other wearables
Faster Firefox
Firefox 84 brings HW acceleration to Linux
Distro watch
What’s down the side of the free software sofa?
IT’S GOOD TO SHARE
Alyssa Rosenzweig is a software engineer based at
TIME’S UP FOR OLD KIT
Jon Masters has been involved with Linux for
Kernel Watch
Jon Masters summarises the latest happenings in the Linux kernel, so you don’t have to
Mailserver
Write to us at Linux Format, Future Publishing, Quay House, The Ambury, Bath BA1 1UA or lxf.letters@futurenet.com.
Helpdex
shane_collinge@yahoo.com WRITE TO US Do you have a
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to lxf.answers@futurenet.com
SUBSCRIBE!
EiskaltDC++
FILE-SHARING APPLICATION
TabFS
FILE SYSTEM
TuxPaint
DRAWING APPLICATION
Chipmunk
LOG VIEWER
Darktable
PHOTO EDITOR
EasyLogic Studio
CSS AND SVG EDITOR
Zenith
SYSTEM MONITOR
Tux Vs Yeti
PLATFORMER GAME
Invasion
ARCADE GAME
Qsnapstore
SNAP STORE VIEWER
REVIEWS
AMD Ryzen 5 5600X
As Alan Dexter discovers, this chip may be the runt of the Zen 3 family, but it delivers where it counts most: gaming
Slackel 7.4
Before he couldn’t work with Arch, he couldn’t work with Slackware, which is why Mayank Sharma jumps at everything that mentions the venerable distro
RebornOS 2020.12.28
The constant deluge of Arch-based distros can put anyone to sleep, but this one makes Mayank Sharma wake up from his slumber
Rescuezilla 2.1
With perennial fat fingers, Mayank Sharma has been messing with hard disks long enough to know that good rescue tools are worth their weight in gold
Garuda Linux 210101
Mayank Sharma has enjoyed one Arch-based distribution this month, but will lightning strike twice or has he been taken in by the distro’s tall claims?
Wasteland 3
Management simply hates weirdos and snow, so this is a bad time of year for them and they’re taking it out on Jody Macgregor
Roundup
Game engines
There’s never been a better time to get into game development on Linux. Michael Reed puts five capable engines under the microscope
How free is it?
There are different kinds of free…
Community and support
A game engine is useless without a way of learning how to use it
Programming environment and GUI
A difficult environment can lead to eventual loss of interest
2D workflow and features
Top down, overhead, side on or something else?
3D workflow and features
How easy is it to create a world to move around in?
Extras
Anything that makes it stand out from the rest?
Ease of use
This is relative because some engines are more capable in terms of what they can do
Game engines
The Verdict
Better virtual machines
BETTER VIRTUAL MACHINES
Forget about the draconian confines of reality and immerse yourself (well, your computing) in a virtual world. Jonni Bidwell’s here with a machines-inside-machines extravaganza
A virtual history
Datacentres are full of VMs, but why and how did they get that way?
QEMU, KVM and the other ones
Learn about virtualising the Linux way, with libvir t and Virtual Machine Manager, and jokes about Inception
Orchestrating with Xen
Set up a machine dedicated to hosting VMs with yet another high-powered hypervisor, XCP-ng
INSTALL XCP-NG
1 Launch the installer Fetch the latest ISO
Contain yourself
Containerisation is even more of an ugly word than virtualisation, but it’s a big deal too. A Docker whale-sized big deal, as we’ll discover…
IN-DEPTH
THE LINUX GAMBIT
Jonni Bidwell once again sets a graphics card on fire, this time calculating chess positions…
Pi USER
PASSING ON THE KNOWLEDGE
Thierry Chantier is a French coder and maker.
Pi Foundation boosts support for teachers
Over 300 free curriculum-mapped video lessons now available via the Oak National Academy
Cool HAT dude!
This Pi Smart Fan HAT is stackable and GPIO friendly, too
Raspberry Pi Pico
In a break from the norm Les Pounder tests the latest Pi: a $4 microcontroller featuring the first ‘Pi Silicon’ created by Raspberry Pi
Turn a Pi HAT into a Magic 8-ball project
SENSEHAT
Connect, configure and use gamepads
GAMING
TUTORIALS
A terminal multiple window manager
You can’t use the mouse or run multiple windows in a text environment… unless you’re Shashank Sharma and know just the right tool for the job
Construct your own mind-maps
Nick Peers reveals how you can easily manage all of your thoughts – from simple ideas to fully formed projects – with this powerful free tool
Next-gen filesystem management
ZFS is a lot more than a filesystem. Neil Bothwick tells all about this advanced volume manager and Swiss Army Knife of filesystems
Run a classic BBC Micro under Ubuntu
Les Pounder reminisces about that one time when he caused a core meltdown in a nuclear reactor, then flew away in a spaceship
Decode signals from weather satellites
Weather satellites transmit signals that you can receive and decode to generate images of the Earth. Mike Bedford shows you how
Dify
IMAGE COMPARISON TOOL
Using Active Directory with Debian & Samba
Stuart Burns rolls up his sleeves and
CODING ACADEMY
Coding Arm 64-bit assembly language
Continue writing 64-bit assembly code for the Pi with John Schwartzman, who calls on Linux kernel services and the C run-time library
Write a maze runner game in Python
One way in, and only one way out… video game aficionado Calvin Robinson reveals how to create a vintage maze runner-style game
REGULARS AT GLANCE
On the disc
Discover the highlights from this month’s packed DVD!
GeckoLinux 152
SUPER GECKO MUSCLES
Chat
X
Pocketmags Support