Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
cc/store
RASPBERRY PI 3B+
Fully Benchmarked Engineering Team Interview Perfect Project Ideas
Power Over
Ethernet
5GHz WiFi
1.4GHz CPU
Power Management
Gigabit Ethernet
BUILD AMAZING
Also inside: BATTLE ROBOTS
> CREATE A RASPBERRY PI SMART FAN How to win at Pi Wars 2018
> THE NINTENDO SWITCH-STYLE CONSOLE
> MAKE YOUR OWN MIDI DRUM SEQUENCER
> CODE A MINECRAFT HOUSE WITH PYTHON magpi.cc/store
Welcome
WELCOME TO
THE OFFICIAL
MAGAZINE PAGE 2
8
This magazine is printed on paper sourced from The MagPi magazine is published by Raspberry Pi (Trading) Ltd., 30 Station Road, Cambridge, CB1 2JH. The publisher,
sustainable forests and the printer operates an editor, and contributors accept no responsibility in respect of any omissions or errors relating to goods, products or
environmental management system which has services referred to or advertised in the magazine. Except where otherwise noted, content in this magazine is licensed
been assessed as conforming to ISO 14001. under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0). ISSN: 2051-9982.
PI WARS
Everything you need to know about the robotic contest
64
IN ASSOCIATION WITH:
97
> NEWS 06
> TECHNICAL FAQ 62
> BOOK REVIEWS 80
> FINAL WORD 98
COMMUNITY
> RPI ZWEI INTERVIEW 84
30 Making a music album with the Pi as the instrument
AMBIENT TV
> THE MONTH IN RASPBERRY PI 86
Birthday parties and new Pi models galore this month
> EVENTS 92
PI SWITCH 32 Jams, Dojos, and Clubs around the world next month
CODE CLUB
IN WESTMINSTER
Showcase event for MPs and Lords “a special experience”
Code Club’s Dan Powell talking
ode Club came to was invited to “simulate a Code
C
with some of the pupils from
Coppice Primary School Westminster in January, Club in Portcullis House,” says
to demonstrate how Dan Elwick, Code Club regional
a Code Club works to MPs coordinator, London & East
and Peers. The event was of England.
organised by Lloyds Banking Code Club participated “to raise
Group, hosted by Labour MP awareness within the Houses of
Wes Streeting, and Code Club was Parliament, as well as to staff in
invited to take part. Lloyds Banking Group, about what
Coppice Primary School, from Code Club is, and how it works,”
Wes’s Ilford North constituency, Dan explains to us.
about what Code Club is matter to Britain, such as building digital skills and
tackling social disadvantage.
Sarah reveals, “There are around 700 [Lloyds
environment.” It also allowed then ‘click’ to catch them,” says Banking Group] colleagues registered with us
politicians to see a Code Club in Dan. The second was Clone Wars, now”, while Lloyds Banking Group “has also started
action, and talk to children about a “Space Invaders-style game, a pilot of Code Clubs in some of its branches.”
their coding skills. “Children were where you’re shooting lightning
so excited to be there and the bolts at hippos that are falling
MPs clearly enjoyed it too,” Dan from the sky.” Gareth Thomas, a Senior
Manager at Lloyds, discusses a
tells us. “There was a real buzz in Both projects are on the Code
project with two young coders
the room.” Club Projects webpage (see
The event ran for an hour and magpi.cc/unpyFy) and use Scratch.
a half, over a lunchtime. In that MPs and Peers from Parliament
time the 28 pupils from Coppice chatted with the children as
Primary created one of two games, they worked on their games.
based on Code Club projects. “The children found that really
interesting,” Dan confirms. “I
Playing politics heard one of the Lords saying
The children were a “mixed cohort to the children, ‘And that’s why
[of] Code Club members and you should all stand for election
selected pupils from years 4, 5, in your local area when you
and 6”, Dan explains. Code Clubs grow up!’”
OPENAUTO:
ANDROID AUTO RUNNING
ON A RASPBERRY PI
Upgrade your car’s navigation and entertainment system
oftware engineer Michal Android Auto essentially
S Szwaj has released an
open-source Android Auto
allows an Android smartphone
to ‘project’ its interface onto
emulator called OpenAuto, which another screen, but while this
runs on a Raspberry Pi 3. “sounds trivial,” Michal reveals
Michal’s motivation for the that actually “projection requires
project was straightforward: he processing a huge amount of data”
wanted to retrofit his car and use as the projection system needs to
Android Auto while driving. “I display the Android Auto screen,
wanted to keep my car’s original play sounds, and relay user inputs
head unit to preserve the design of to the smartphone as quickly
the dashboard,” says Michal, but as possible.
his car is “14 years old, so its head Michal reveals, “The challenge
unit is far, far behind the modern is to handle projection on [a
head units.” Raspberry Pi], where RAM and CPU
Thankfully a Raspberry Pi 3 utilisation is very limited and even
has “a lot of advantages” for a small bottleneck leads to audio or
OpenAuto, as Michal lists: “It video glitches.”
is very cheap, [has a] multicore
processor, hardware video In-car entertainment
decoding, OS based on Linux, Michal continues, “The most
support for the MCP2515 CAN Bus important thing to implement
Above OpenAuto is an Android Auto emulator, allowing your
Android smartphone to ‘project’ its interface onto your car’s screen module, and RCA video output.” [for successful emulation] was
support for hardware acceleration
of video decoding.”
He tells us, “As far as I know, all
Android Auto POCs use GStreamer
to render the video stream.” Alas,
“GStreamer used on the Raspberry
Pi does not provide plug-and-play
support for OpenMAX,” according
to Michal’s research. This means
that OpenAuto’s video is “pretty
slow, even at 480p@30[fps].”
As such, Michal cannot
recommend you install OpenAuto
in your car just yet, but by the time
you read this, version 1.0 of the
software should have been released
for you to trial on a bench.
OpenAuto runs on a Raspberry Pi 3 Head to magpi.cc/cbSUyr to
– the microphone is provided via the
USB sound card see how to install OpenAuto
in Raspbian.
WINDOWS
10 UP AND
RUNNING
Full-fat Windows 10
with your Raspberry Pi
Above Look very closely – that’s the
oftware engineer Bas Bas tells us that he used both
S
Broadcom BCM2837 processor of a
Timmer managed to get standard versions of Windows, Raspberry Pi listed in Windows 10’s
Device Specifications
the full, x86 version of as well as the ARM64 version,
Windows 10 running on a Raspberry to compare codebases. His first nearly everything were missing, so
Pi 3. But it wasn’t easy. attempt, to port the “UEFI Bas had to write “a hacky driver”
version from the IoT Core” to just to get a USB keyboard to work.
boot into Windows didn’t work out. Curiously, Bas found that
Instead, Bas “added the required Windows 10 has support for “a
features to run Windows (ACPI special interrupt controller” used
tables) to an open-source UEFI I’d in the Raspberry Pi’s Broadcom
found for the RPi on GitHub [see processor “that’s not usually used
magpi.cc/guhzUy].” in ARM chips.”
After “some days of debugging”, You can read about Bas’s
Bas managed to get into the progress, and see new updates,
Windows boot/install environment. through his Twitter account
Unfortunately, the drivers for @NTAuthority.
RASPBERRY
FIELDS FOREVER
New Raspberry Pi summer festival launched
his summer sees the everything that makers have learnt
T first Raspberry Fields
‘community celebration’,
and achieved since the Raspberry Pi
was launched six years ago.
held in the home of the Raspberry The weekend will include
Pi – Cambridge, UK. opportunities to learn about the
Held over the weekend of Saturday amazing projects that community
30 June and Sunday 1 July, the new members are working on, try
annual festival is a celebration of activities, watch fascinating
science and technology talks,
and generally celebrate all things its volunteer community of young Above The
first Raspberry
Raspberry Pi and digital making. people, hobbyists, educators, and
Pi festival is
There will also be face-painting, enthusiasts of any age and skill. happening this
summer, on
fun performances, free giveaways, Tickets cost £5 for over-16s and
Saturday 30 June
delicious food, and other are free for under-16s, bought and Sunday 1 July
festival-themed activities to get from the Cambridge Junction
involved with. site before arriving. Head over to
The festival will be led by the raspberrypi.org/raspberry-fields
Raspberry Pi Foundation, but run by for more information.
NOW TRENDING
The stories we shared
that flew around the world
RASPAD
magpi.cc/cqetsf
TABLET
yourself an IoT device ready to monitor the world.
raspberrypi.org/magpi April
April 2018
February 2017 11
News RASPBERRY BOOM / FARNELL LAUNCHES CLOUDIO
RASPBERRY BOOM
Detect aurorae, heavy traffic, or meteors on your Raspberry Pi
rom the makers of the device and software will filter
F Raspberry Shake – a
seismograph for your Pi
background noises.
You can connect your Raspberry
– comes the Raspberry Boom, a Boom device to the Station View
device to detect ‘infrasonic’ noises network to create a global network
undetectable by the human ear. of sensors. Mike also clarifies, “We
While the Shake detects have a few ways for users to grab
movements, the Boom detects the data in real-time
noises, so it can discern just and integrate into
about any event, from avalanches their own websites,”
and breaking icebergs to lightning Full details are at
and transport. magpi.cc/jJBvsM.
The sensor detects sound The Raspberry Boom
waves of 0.05–20 Hz, way below is being launched via
typical human hearing. But Mike Kickstarter, so head to
Hotchkiss, consumer marketing magpi.cc/cadepc for pricing
manager for Raspberry Shake, and more information.
confirms that “the Raspberry
Right The Raspberry Boom detects
Boom was designed to be
extremely low-pitched noises, allowing
operated in your home” – the you to detect almost anything
FARNELL LAUNCHES
CLOUDIO
IoT meets app-like simplicity
raspIO’s Cloudio add-on
G board has a huge range
of hardware and sensors
to make your first steps into IoT a
breeze. It’s even programmed with monitor, dashboard, and Above GraspIO’s
Cloudio makes
a drag-and-drop (Scratch-like) custom notifications. it simple to build
interface, so you can set up your Hari Kalyanaraman, Farnell’s and program a
sophisticated IoT
device from your phone. global head of emerging business, device in minutes
With voice, IR, light, and tells us, “Graspio Cloudio is aiming
temperature sensors built in, to make things simple for those
you’ve got plenty of IoT abilities people with little or no coding
baked in to the Cloudio board, experience to create applications…
including a 0.96-inch OLED The goal was to make it easy for
display. But there are also three anyone to build IoT projects and
ADC ports, a mini servo-motor get up and running in minutes.”
port, and three digital output ports The Cloudio board costs £33
to incorporate extra abilities. from magpi.cc/XbqhhF, and is
The app also supports compatible with all versions of
IFTTT integration, a sensor the Raspberry Pi.
RASPBERRY PI
Above left OpenCat
uses an Arduino to
handle the robotics,
and a Raspberry Pi
ROBO-CAT
to provide higher
functions such as
Alexa support
Above An early
iteration of OpenCat,
using modelling sticks
to make the body
Gaited development
Rongzhong studied many mammalian gaits, and believes
“different gaits can be generated by simple tuning
amplitude, phase duration, and other tiny parameters”.
OpenCat is “not constrained by [being a] cat.”
He found that he had to use an Arduino ‘slave’ to
handle the robotics, while the Raspberry Pi handles
higher functions such as the Alexa integration.
Currently, OpenCat uses Alexa “to trigger certain
behaviours,” but there are also references to ‘hosting
video streams’ through OpenCat. As Rongzhong says,
voice assistants “can now run on a pet-like body, and
interact with people in a pet-like manner. [This] may
encourage more people to embrace robotics at home.”
Rongzhong is currently developing ways to make
OpenCat financially self-supporting – whether that
means selling OpenCat kits or something else, we’ll
have to wait and see.
RASPBERRY PI
Ptola c e s UK
The Pi Hut
CPC
magpi.cc/aIgkOF
Pi Supply
Buy
magpi.cc/zVTpyC magpi.cc/LktvfU
Forthings.io ModMyPi
magpi.cc/KYJbMi magpi.cc/rMXCsW
Pimoroni RS Components
magpi.cc/LhuKdS magpi.cc/nDkZGZ
Still n
ot su
wher re
e to g
Rasp et yo
ber ur
Visit th ry Pi from?
e official
and cl
ick Bu page
magpi y No
.cc/pO w!
North America Europe yjBN
MEET THE
RASPBERRY PI 3B+
A plus in the name hides a wealth of new hardware
and design tweaks in a classic footprint
C B
Running at 1.4 GHz,
the revised system-
A
on-chip (SoC) design
includes brand-new
package technology
Designed by Proant,
the new ground-
Shielded under a metal plane antenna offers
B C
plate, the new radio module improved performance
includes dual-band 2.4 GHz over the Raspberry Pi
and 5 GHz WiFi compatibility 3B+’s chip antenna
QUICK SETUP
SoC: RAM: Ports:
Broadcom BCM2837B0 1GB LPDDR2 SDRAM HDMI, 3.5 mm analogue
quad‑core A53 (ARMv8) audio-video jack, 4× USB
64-bit @ 1.4 GHz
Bluetooth: 2.0, Ethernet, Camera Serial
Bluetooth 4.2, Bluetooth Low Interface (CSI), Display Serial
GPU: Energy (BLE) Interface (DSI)
Broadcom VideoCore IV
GPIO: Dimensions:
Networking:
40-pin GPIO header, populated 82 mm x 56 mm x 19.5 mm
Gigabit Ethernet, 2.4 GHz and
Storage: microSD Weight: 50 g
5 GHz 802.11b/g/n/ac WiFi
>STEP-01
Download an operating system
You’ll need an operating
system, available from
E
raspberrypi.org/downloads, to use
your new Raspberry Pi. Raspbian, the
Foundation’s official operating system,
is the best choice for most users.
An optional Power-over-
E
Ethernet (PoE) HAT module,
available separately, can
power the Raspberry Pi 3B+ >STEP-03
Connect the cables
Insert the microSD card, then begin
connecting cables. For most users
A clever power these will include an HDMI display, a
management integrated USB keyboard and mouse (or Bluetooth
F
circuit (PMIC) replaces receiver for them), an Ethernet cable
discrete components and (optional), and finally a 2 A or higher 5 V
provides smoother power micro-USB power supply.
BENCHMARKING
THE PI 3B+
The promise of improved performance is one thing, but there’s
only one way to get to the truth of the matter: benchmark testing
ith an upgraded processor tests, measuring everything from a knock-on effect on memory
W boasting impressive new
packaging and improved
raw CPU performance to power
draw and WiFi signal quality.
performance, too, while the
new USB Ethernet controller
networking capabilities, the offers Gigabit connectivity
Raspberry Pi 3B+ should sit Spec comparison at a theoretical maximum
head and shoulders above its Although it’s the same underlying throughput of 300 Mbps, due
predecessor the Raspberry design as on the Pi 3, the Pi 3B+’s to its use of a single USB 2.0
Pi 3. To determine whether these BCM2837 system-on-chip (SoC) channel. Finally, a switch to a
improvements are noticeable in is now in spin B0 and features new dual-band radio module
the real world, the Pi 3B+, along improved packaging alongside and antenna design inspired
with the Pi 3 and a range of other a heat-spreader, which have by the Pi Zero W improves the
board models, have been put helped boost its performance Pi 3B+’s connectivity compared
through a series of benchmark from 1.2 GHz to 1.4 GHz. This has to its predecessor. 311.5
Higher is better
181.9
SYSBENCH CPU
343.06 SINGLE-THREADED (SECS)
339.21
336.91 337.02
MULTI-THREADED (SECS)
Lower is better
233.83 235.86
A synthetic benchmark designed
218.53
to stress the central processor,
SysBench’s CPU test highlights the
139.22
performance gains available to CPU-
119.22
bound applications – in particular
those which can take advantage
54.55
of the multiple processing cores 34.97
30.04
available on the Pi 2, Pi 3, and Pi 3B+.
THROUGHPUT
632.27
547.9
Higher is better
425.87
ETHERNET
212.9
THROUGHPUT (Mbps)
THROUGHPUT
Higher is better
WIFI SIGNAL 66 66
67
PI 3B+ SIGNAL QUALITY
46 45
A head-to-head shoot-out between 40 39
the Pi 3’s single-band 2.4 GHz WiFi 36 34
35
radio and chip antenna and the Pi 32 34 32
32
26
3B+’s new dual-band 2.4 GHz and 5 GHz 23
radio with ground-plane antenna
offers a look at the improvements you 0 0 0 0 0
UPDATING THE
RASPBERRY PI
Eben Upton, co-creator of the Raspberry Pi and co-founder of the Raspberry Pi
Foundation, delves into the technology that makes the new Pi 3B+ special
hen working on a new through probably four or five
W Raspberry Pi design,
there’s one thing Eben
process shrinks between Pi 1 and Pi
3B+. I don’t think we’re spending
Upton always keeps clear in his significantly more on RAM now,
mind. “It’s a Raspberry Pi, so it despite having quadrupled the
costs $35,” he laughs. amount of RAM in the device.
Delivering constant “The other thing is a gradual
improvements without increasing increase in the amount of silicon
the price is a challenge, but one we can put in the design. More
the Raspberry Pi Foundation and more of the BOM (the bill
welcomes. “Over time, there are of materials) is silicon, and the
a couple of things that help,” reason for that is that the cost of
Eben explains. “One is obviously manufacturing Raspberry Pi keeps
a Moore’s Law thing [the going down because of automation.
observation by Intel co-founder There are still investments going
Gordon Moore that the number of on in automation now that are
transistors on a new chip doubles taking costs down. The other thing
every 18 months], where you can is connectors: I pay a lot less for an
genuinely get more silicon for HDMI connector than I used to, and
your money. That particularly that’s just economies of scale.”
applies to RAM: DRAM [dynamic
random access memory] has gone
GET STARTED
WITH YOUR
RASPBERRY PI 3B+
Is the 3B+ your first Raspberry Pi? Here’s what you need to know…
veryone’s got to start Connecting to WiFi
E somewhere, and if you’ve
ever seen the rate Pi boards
Plugging in an Ethernet
cable is easy and the
are sold we’d hazard a guess that only problem you’ll
the 3B+ will be someone’s first tend to encounter
Raspberry Pi. If so, welcome to is not having a long
the community! We’ve got some enough cable, in which
great tips on where to start on your case you’ll have to connect
grand Raspberry Pi adventure. using the Raspberry Pi’s built-in
wireless capabilities. This is very
easy in Raspbian – simply look in
the top right-hand corner for the
wireless symbol…
READ THE
MAGPI 65
Everything a total
newcomer needs
to know is found in
issue 65, available
as a free download.
> magpi.cc/65
TEN PROJECTS
TO POWER UP!
Here are some projects that can be made better with a Pi 3B+!
EASY RETRO
GAMING ON A
RASPBERRY PI
> magpi.cc/BmPQxg
While old computers and consoles
are far less powerful than a
Raspberry Pi, emulating them
properly uses up a lot of processing
power. With the extra oomph the
Pi 3B+ provides, true emulation is
a step closer on the Raspberry Pi.
IMAGE EDITING
DATASCIENCEPI ON YOUR
> magpi.cc/GBNqkB RASPBERRY PI
The original version of this project > magpi.cc/xiyAqr
uses a Raspberry Pi Zero to do Image editing uses up a fair
some data crunching. Its creator amount of resources. While
Scott Edenbaum has tested his Mirage on a Raspberry Pi is a
setup on a Pi 3 before, saying it bit less power-hungry than a
takes about two hours to build on 50-layer Photoshop project,
there and even longer on the Pi having a higher CPU speed to
Zero. With the extra power the 3B+ render or make changes can
affords, can it be done in under be very handy to help speed
two hours? up your workflow
SENSE HAT
DATA LOGGER
> magpi.cc/CYrngd
Logging data from the Sense HAT is BUILD A LIGHTWEIGHT
fairly easy for the Raspberry Pi to do. PYTHON WEB SERVER
So why not use the spare processing > magpi.cc/bWyKaz
power to do something useful with While similar to the LAMP server, this one is
BUILD A the data? Create a live analysis or a bit lighter, meaning it uses fewer resources.
WEB SERVER crunch any numbers? It’s always Using the Raspberry
> magpi.cc/dhKtSK good to multitask if you can. Pi 3B+, you can max
This one can make use of both the out your efficiency
Raspberry Pi 3B+’s extra processing with a server
power and enhanced network running Flask, and
connectivity to perform better than even use your Pi
ever before. Even the improved 3B+ for other stuff
wireless helps out here! in the meantime.
OCTAPI: RASPBERRY PI
CALCULATING PI PROJECTS 3
> magpi.cc/PptaMu
The OctaPi is a cluster computer Discover more
using eight Raspberry Pis. Hence inspirational
the name. Pooling the Pis’ projects for
resources together helps you Raspberry Pi
calculate faster, especially when in The Official
it comes to irrational numbers Raspberry Pi
like π (pi). What’s better than Projects –
eight Pi 3s? Eight Pi 3B+ boards. Volume 3 book.
Time to set some speed records. > store.rpipress.cc
SAVE
UP TO
35%
Pricing
Rolling Subscription
£4 a month
Quick and easy to set up
£5 FREE! MODMYPI
VOUCHER
FOR ALL SUBSCRIBERS
No long-term commitment
* Leave any time applies to Rolling Subscription only
magpi.cc/subscribe
28 April 2018 raspberrypi.org/magpi
Tutorial
JOIN FOR 12 MONTHS AND GET A
PI ZERO W
STARTER KIT
WITH YOUR SUBSCRIPTION
Subscribe in print for
WORTH 12 months today and
£20 you’ll receive:
Pi Zero W
Pi Zero W case
with three covers
Camera Module
connector
SUBSCRIBE ON
APP STORES
FROM
£2.29
raspberrypi.org/magpi April 2018 29
Projects SHOWCASE
JIMMY WHITE
Jimmy describes himself as a “geek, DJ,
Since it relies on a webcam rather photographer and father”. His son loves
than a source, this system works his TV so much, Jimmy built him one.
regardless of what’s being shown, deviousweb.com
whether a film or game.
Quick
Facts AMBIENT
TV LIGHTING
> The software,
Ambient
LightServer, is
open source
Quick
Facts
> The Joy-Cons
can be used
for two-player
gaming
PISWITCH
New meets old in Christopher Foote’s take on the retro-gaming
> PiSwitch boots
handheld console thanks to Nintendo’s latest innovative controllers.
to Chris’s own
touchscreen
David Crookes reports
menu
ne of the most popular game a year to play (“two if I Having discovered the Switch
> The 6600 mAh
battery offers a
2.5-hour life
O things to do with a
Raspberry Pi is to put it at
was lucky,” he says). He recalls
spending countless hours trying
Joy‑Cons were Bluetooth devices,
Christopher got to work pairing
> PiSwitch the heart of a retro gaming setup. to accomplish everything he them with a Raspberry Pi. “I spent
can also be There are myriad multi-system could in those titles. “But there a lot of time trying to connect
plugged into
emulators – programs which were always many games that I two of them to work as a single
a TV
replicate the gaming systems wanted to play but I couldn’t,” controller and I thought if I could
> An optional
of old – along with some slick he laments. solve that problem, then the rest
camera was
added for fun graphical front-ends, making Spurred on by this, he began would be a cakewalk,” he says.
it a rather straightforward using RetroPie a few years ago to
process. But we still see projects enjoy games made for systems as Mapping controls
that go the extra mile such as diverse as the Atari 2600 and Mega He compiled Linux Joystick Mapper
this one. PiSwitch makes great Drive. But although he ran it on a on his Pi 3 before mapping the
use of the Joy-Con controllers Adafruit’s PiGRRL2, he found the controllers to keyboard keys and
of the Nintendo Switch buttons were sticky and he didn’t mouse buttons. “It worked great
console to produce a beautiful like the screen. “Then my wife got apart from the analogue sticks, so
handheld machine. a Nintendo Switch for my son and I looked through the code for a few
PiSwitch is the brainchild of when I played with it I realised hours, figured how Linux Joystick
32-year-old Christopher Foote the controllers were exactly what I Mapper worked, and reprogrammed
who, as a child, would get one needed for my device,” he tells us. it for Joy-Con compatibility.”
was added.
load different controller maps.”
>STEP-01
Connect the controllers
Fitting perfectly This ensures they work well with
The controllers must be woken at the boot menu by
One of the lovely parts of the build retro games whether as a single
tapping the + and – buttons. “Nintendo makes the
is the way the Joy-Cons click into controller or separate ones,
Joy-Cons go to sleep when they’re not in use, to save
place to the left and right of the but also as a mouse or to flip
battery,” says Christopher.
screen, just like on a Nintendo through media on Kodi, which
Switch. “I took my Switch and he also installed.
>STEP-03
Play a game
You need to copy a game ROM to the microSD card.
This is a digital version of a game cartridge. By
The rough 3D-printed case needs
refinement, but it contains access selecting the right console and the game in RetroPie,
points for the jack, the microSD card,
you can have some fun.
and the Raspberry Pi’s HDMI port
Quick
Facts
> The name
comes from
‘QR’ and
‘crocodile’
QROCODILE
A snappy idea, making it easier to control a Sonos multi-room
speaker system, as Nicola King discovers
> It can play
music in a een to find a way to enable Sonos apps to search for music or to a Raspberry Pi 3, housed in a LEGO
selected room
CREATING A
QROCODILE
>STEP-01
Croc case
The crocodile-shaped case houses the Raspberry Pi 3,
QR code card holder, and mini camera. It’s built from
green LEGO bricks belonging to Chris’s son. This was
the easiest part of the project.
Above The cute croc-shaped case is built from his son’s green LEGO bricks
Chris spent around four weeks So, what do his children think of
working on the project in his their dad’s invention? “They love
spare time, ironing out several it! My son likes that it allows him to
issues along the way, such as be in control of the playlist for their
with the QR encoding algorithm. dance parties. My daughter enjoys
His first implementation simply being able to play her favourite
encoded the full artist, album, song Starman over and over.”
and song title metadata in the
QR code. “This worked fine No qrocodile tears
for short names/titles, but not So far, no qrocodile-related fights
so well for songs or albums have broken out between the kids. >STEP-02
with really long titles. It hadn’t “They picked up on how to use it Generate codes
occurred to me that the more almost immediately.” A Python script takes a list of songs (from your local
information you cram into a QR For those who’d like to build one, music library and/or Spotify), as well as commands,
code, the tinier those little black Chris has supplied full instructions and generates cards with an icon and text on one
side and a QR code on the other.
PIXEL
and enjoys music, flying,
and making things.
coolfactor.org
Quick
Facts
> The display
weighs around
2.5 kg
ELECTROMECHANICAL DISPLAY
> …Driven by
three Pololu
Mini Maestro
24 boards
> 448 3D-printed Featuring an ingenious rotating pixel design, Gavan Fortune’s
components
were required electromechanical matrix display is most impressive.
> It took over two Phil King reports
weeks of solid
3D-printing
ooking to create a
L
time
decorative project for his Comprising seven 3D parts, As a pixel is rotated, its
each pixel is turned by a vanes emerge from the
office party, Gavan Fortune servo at the rear black casing
decided that a standard LED matrix
display would be too obvious.
“Somehow I started thinking about
electromechanical things like the
flip-dot display and wondered
what I could do that would be a
little bit different,” he tells us.
The result is the Pixel, an
amazing electromechanical matrix
display controlled by a Raspberry
Pi (magpi.cc/tcMzFz). Each of its
64 ‘pixels’ is turned on and off by a
servo rotating a 3D propeller-like
shape to reveal its bright yellow
vanes from a black casing.
Unique design
“I don’t know of any other
implementation of this shape for
a display,” says Gavan. “The idea
came from the AWS visual display
(a.k.a. sunflower) in a train cab,
which in its active state displays
interleaved yellow and black
segments, but this was an exercise
in extending the yellow part to
cover the whole circle. This is not
possible to do with a part rotating Monitor stands add extra
support to the matrix to
behind a shutter, and meant that prevent it flexing
there had to be a third dimension
to the moving part.”
INSTALL
UBUNTU MATE
ON YOUR RASPBERRY PI
Try out this alternative operating system on your Raspberry Pi
buntu is a big name in the Linux world. Like Head to ubuntu-mate.org/download and click on
You’ll
U Raspbian it’s based on Debian architecture,
but it’s run by Canonical Ltd which offers
Raspberry Pi and 16.04.2 (Xenial). Click on Download
Link (or choose the magnet link if you want to be a
38 April 2018
xxxx 2016 raspberrypi.org/magpi
UBUNTU MATE Tutorial
Raspbian, there are two panels at the top and bottom
of the screen. The one on the top has Applications,
Places, and System (plus an icon for Firefox, the web
browser). In the top-right are icons for Bluetooth and
Network, plus the Clock and Shut Down icons.
The bottom panel has a couple of interesting
items. On the left is a Show Desktop icon. Clicking it
hides all the current windows, enabling you to view
the desktop.
Meanwhile, over to the bottom-right is a
Workspace Switcher. You get four different
workspaces (virtual desktops) by default. Clicking
on any of the four screens lets you switch between
them. It’s like having four different monitors and
being able to jump between them (which is great if
your screen gets cluttered up with windows).
Applications
Clicking on the Applications in the top-left accesses
all the built-in software. Ubuntu MATE has a vastly
Above: System
different selection to Raspbian. or by pressing CTRL+ALT+T. (Don’t forget, you Monitor provides
Firefox is the stock web browser. Open it using the can also drag icons to the panel for faster access.) detailed information
on the resources
icon in top panel, or choose Applications > Internet > Ubuntu MATE also supports virtual TTY desktops, being used by
Ubuntu MATE and its
Firefox Web Browser. which you can switch between using CTRL+ALT+F1 various components
You’ll find plenty of other apps to explore inside to F6. Press CTRL+ALT+F7 to return to the main
the other folders. Some – like Scratch 1.4, IDLE, and TTY desktop.
LibreOffice – you’ll be familiar with. Others – like
Minecraft Pi, Sonic Pi, and Sense HAT Emulator – are System Monitor
Raspberry Pi-specific software found in Raspbian and Take a look at Applications > System Tools >
Ubuntu MATE. MATE System Monitor. Here you can find detailed
There’s a lot of office software – like Pidgin information about your Raspberry Pi, including
internet Messenger, Thunderbird Mail, and HexChat the memory, processor, and available disk space.
– to explore. And media programs like VLC Media Click the Processes tab to see what items are
Player, Rhythmbox, and Shotwell enable you to
access video, music, and photo documents.
All of the options can be found in the System
Ubuntu MATE is an interesting
folder. Be sure to check out the Administration
> Software Boutique program. Here you’ll find
alternative to Raspbian,
a curated selection of additional programs you the officially supported
can install.
You can access a Terminal window using operating system
Applications > System Tools > MATE Terminal
running (and you can end stalled processes using
the End Process button). The Resources tab enables
you to see CPU, Memory, and Network usage
over time.
Ubuntu MATE is an interesting alternative to
Raspbian, the officially supported operating system.
It lacks a lot of the functionality, especially advanced
programming tools like Thonny and Scratch 2.0.
And there are no built-in links to all the resources
developed by Raspberry Pi, which makes it less
useful for learning programming. It’s also a bit of a
resource hog compared to the lightweight approach
of Raspberry Pi Desktop.
But if you want to try out a different operating
The Software Boutique is used to system, and use a bunch of powerful software on
recommend programs for you to install
the Raspberry Pi, it’s well worth a look.
MIKE’S PI BAKERY
Veteran magazine author from the old
days and writer of the Body Build series.
Co-author of Raspberry Pi for Dummies,
Raspberry Pi Projects, and Raspberry Pi
Projects for Dummies.
magpi.cc/259aT3X
MIDI DRUM
SEQUENCER Make your own nine-channel drum sequencer
You’ll
Need A
drum sequencer, or drum machine, is a
staple part of virtually every music making
we mentioned in passing. These cover both General
MIDI 1 and General MIDI 2 standards. General MIDI
system. Gordon Sumner (who, for younger (GM for short) is an agreed mapping between an
> MIDI sound
generator
readers, is also known as Sting from the rock combo instrument number and its description. Before
The Police) once joked that the difference between a the advent of GM, it was down to the equipment
> Four
potentiometers drum machine and a drummer was that you only had manufacturer to assign what instrument number
with knobs and to punch the rhythm into a drum machine once. So produced what sound; this meant that to get correct
coloured tops we are going to show how to make your own drum MIDI playback you had to use the same sound
> Box for pots like machine using Python on the Raspberry Pi. module as was originally used when creating the
the Maplin FT31 The MIDI sound module that we made in Pi Bakery MIDI files. Some sound modules still have their
> Stripboard: in The MagPi #63 has a set of percussion voices that own sound mapping, but GM does make things a lot
17 strips of more flexible.
14 holes
For percussion, things are a little different from
> MCP3008
the normal melodic instruments. Where, if you select
> 16-pin IC socket say a tuba, using program message 59, then the note-
> Bottom-entry on-message numbers give you different notes of the
twin-row music scale played on a tuba. With the percussion,
header sockets,
if you select a percussion bank, the percussion
24 contacts
at least instrument you get will depend on the ‘note on’
message number. Valid numbers range from 27 to 87,
> 10-pin
single‑row so that is 60 different instruments.
header socket Note here how we said that the sound description
> 1 × 0.1 uF is standardised; this does not mean the actual sound
ceramic will be exactly the same. So while in percussion
capacitor
Figure 1 The screen layout for the drum sequencer a ‘note on’ number of 60 is described as a ‘High
Bongo’, how good this actually sounds will change in a sequence and while we have decided to have 16
from synth to synth. hit points, you can, with a software option, make it
repeat after the first four or first eight hit points. For
Design a sequence length of four, the hits are every beat in
Most drum sequencers generally have the same form a bar or whole notes. Half notes give you a sequence
of grid layout: horizontal rows define the firing point length of eight, whereas quarter notes produce a
in a sequence for one instrument, and these rows length of 16 steps. So the W, H, and Q keys define the
are stacked for as many instruments as you want number of steps in a sequence.
to have playing in your loop. The length of the row In addition, you want to be able to select at what
defines the number of beats or hit points you have point an instrument sounds; for that, the grid
3V3
3V3
3V3 Gnd
Pots all 10k
Volume Velocity Pan Reverberation
16
1 A0
15 A1
2
IC 2 A2
0.1uF 3
Raspberry Pi MCP3008 A3
GPIO connector 4
A4
Din 5
GPIO 10 11 A5
Dout 6
GPIO 9 12 A6
7
CLK A7
GPIO 11 13
8
CS
GPIO 8 10 9 14
Gnd
Figure 2 Schematic of the control circuitry
MAKING THE CONTROL squares are clicked to select firing or not. You also
need to start and stop the sequencer. In order to get
INTERFACE BOARD a good mix, you need to be able to control the volume
and the hit velocity of each instrument, its position
in the stereo field, known as pan, and also control
the amount of reverberation applied. This is done by
>STEP-01 using four knobs to adjust each parameter. Only one
Preparing the board sound can be adjusted at a time, but once adjusted,
its settings are stored and the next channel can be
Take a piece of stripboard 17 strips wide by 14
adjusted. The instrument adjusted by the knobs is
holes high, and break the tracks shown by the
selected by the number keys 1 to 9 on the keyboard,
light grey areas (below) with a scalpel or spot face
with the 0 key locking all instruments against
cutter. The dotted lines show the positions of the
IC socket. Most of the board will hang over the change. Coloured lines representing each parameter
side of the Raspberry Pi. are drawn over on the right of the screen, with each
colour matching the top of the labelled knob. The
screen layout is shown in Figure 1 (page 40).
The – and + keys alter the speed of the steps,
and the C and R keys clear the grid and reset the
sequence. The I key is when you want inspiration:
it gives you a starting point for a rhythm.
The hardware
The hardware consists of four potentiometers in a
box connected to an analogue-to-digital converter
(ADC) attached to the SPI GPIO pins of the Raspberry
Pi. We used an MCP3008 eight-channel converter,
Software design
While we’re using our normal Pygame framework,
this project posed a bit of a problem when it came
to selecting the instrument for each track. The
obvious solution is a menu, but Pygame doesn’t
support them, especially one with a choice of 60
instruments, so to get round this we have to be
slightly devious. The solution we came up with is
to use the Tkinter framework to create a very small
window with just a menu button visible, then clicking
on that button would open the menu. This produced A7 A6 A5 A4 A3 A2 A1 A0 Gnd 3V3
a further complication in that we wanted this menu
to pop up in the place we clicked. It turns out that
Tkinter requires a mouse position based on the whole
>STEP-03
Wiring up
screen, whereas Pygame tells you about the mouse
position referenced to the Pygame window. To get
Wire up the chip and GPIO socket according
round this we had to import the pymouse module, to Figure 2; a physical representation of this is
which is now part of the pyuserinput package. So we shown below. Note the wire from the power strip
had to type into a Terminal window: goes to pin 16 of the chip and carries on under
the board to pin 15 of the chip. The analogue
sudo pip-3.2 install xlib inputs to the chip are in the correct order for the
sudo pip-3.2 install pyuserinput header strip.
MCP 3008
3V3 Gnd A0 A1 A2 A3 A4 A5 A6 A7
>STEP-04
The potentiometer box Percussion_sequencer.py
001. # MIDI percussion sequencer with Pots control
Drill 7 mm holes for the shaft of the pots. Then
002. # By Mike Cook February 2018
push the pots in from the top of the box to mark
003. import pygame, os, time, random
the place for the anti-rotation pip. Use a 1 mm drill
or router to make a slot for this pip so the pot sits 004. import functools, rtmidi
flush. If you must, you can cut off the pip. Wire 005. from pymouse import PyMouse
up the pots before mounting them in the box to 006. from tkinter import *
make things easy for yourself. Fit the knobs, tops, 007. import spidev
and labels. Connect to the board as per Figure 2. 008.
009. midiout = rtmidi.MidiOut()
010. pygame.init() # initialise graphics interface
011. os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'
012. pygame.display.set_caption("MIDI Percussion sequencer")
013. pygame.event.set_allowed(None)
014. pygame.event.set_allowed([pygame.KEYDOWN,
pygame.MOUSEBUTTONDOWN, pygame.QUIT, pygame.MOUSEBUTTONUP])
015. textHeight=26 ; font = pygame.font.Font(None, textHeight)
016. screenWidth = 1100 ; screenHeight = 670
017. padXm = screenWidth-100 # maximum X of pads
018. screen = pygame.display.set_mode([screenWidth,
019. screenHeight],0,32)
020. instRect = [ pygame.Rect((0,0),(0,0)) for i in range(0,9) ]
# instrument name rectangles
021. instNumber = [9, 8, 11, 14, 33, 34, 20, 21, 30]
# default instrument numbers
022. stopRect = pygame.Rect((0,0),(0,0));startRect =
pygame.Rect((0,0),(0,0))
023. instToChange = 0 ; step = -1 ; random.seed() ; showControls
= False ; controls = 0
collide function to see what object, if any, has been 024. padCols = [(28,28,28),(180,180,0)] ; playCols =
clicked on. [(20,20,20),(50,200,200)]
025. lastStep = time.time() ; running = False ; bpm = 240
The software # beats per minute
The Percussion_sequencer.py listing shows the 026. potValue = [0,0,0,0] ; beat = 16 ; black= (8,8,8)
code, and the program is basically running the 027.
sequencer or not – defined by the variable running. 028. def main():
In reality the rhythm tracks 1 to 9 are actually the 029. global master
MIDI channels 15 to 7. The global reverberation is set 030. createMatrix()
to a maximum and the local channel reverberation 031. initMIDI()
is tamed by the controls. The software reads a file, 032. loadResource()
percussion.txt, comprising a list of instruments 033. pygame.draw.rect(screen,black,(0,0,screenWidth,
called; this is taken from the data sheet of the VS1053 screenHeight),0)
chip we used for the MIDI sound box, but this project 034. drawScreen()
will work with any MIDI sound generator. 035. setBPM(0)
036. while(1):
Taking it further 037. checkForEvent()
While this is designed for a 4/4 time signature, 038. if showControls :
the number of hit points that define the sequence 039. readPots()
repeating length can be changed for alternative time 040. if not running :
signatures. So if you want to play in 15/16 time, say, 041. time.sleep(0.05) # let other code have a look in
change the variable beat to be set to 15 on the press 042. if time.time() >= (stepTime + lastStep) and running:
of some key in the checkForEvent function. Another 043. nextStep()
useful addition would be a box to the left of the 044.
screen to mute individual tracks. You could replace 045. def nextStep():
the variable controls and ADC with key presses that 046. global step, lastStep
increment or decrement the various parameters. 047. lastStep = time.time()
BARTLOMIEJ RUTKOWSKI
Bartek is a DevOps consultant
specialising in Docker, Kubernetes,
and cloud architecture. Programmer,
FreeBSD developer, Magda’s husband,
and dad of Kazik the Alien.
github.com/bartekrutkowski
You’ll
Need INSTALL PLEX WITH
> Wireless
internet access
DOCKER ON
RASPBERRY PI
> Another
computer
Now, to check if you have image is already available, so it didn’t have to pull
it and it passed our text string to the container. The
internet connectivity
application inside generated the picture with the text
and case
magpi.cc/ everyone feels comfortable, especially when these >STEP-02
bpWaTO shared spaces are large. With about 40–50 people in a Attach the other components
> DHT22 sensor room, we can’t all be happy. We’ve put together some After you’ve attached the sensor, mount the display
(on PCB) components, both hardware and software, to keep us on the Raspberry Pi. It slots nicely on top of the
magpi.cc/rVJjfJ
cool. Here’s how you can do the same… GPIO pins, so this should be easy. Now you can build
> USB fan the acrylic case around it to support the display and
magpi.cc/
gTcRve
>STEP-01 protect your Raspberry Pi. Of course, you should
Wire up the sensor make sure the sensor stays on the outside of the case.
First things first: this project is all about monitoring After completing the case, plug the USB fan into your
temperature, so we need to attach the sensor. It’s Raspberry Pi. If your USB fan has a power switch, hit it
MAKE
important to do this before attaching the display. Wire to make sure it works.
IT EVEN
CHEAPER
When the offset is passed, The current temperature is
Although the the USB port will be powered measured constantly and
DHT22 and and the fan turns on compared to the offset
mini table-fan
are relatively
cheap, you
can also use
a DHT11 and
a simple
USB fan.
>STEP-04
Download the software
Open the Terminal (or dial in with SSH from another
computer) to install and download all of the software.
We’ll start with the prerequisites. Install them with
the command:
Now clone and install the sensor module driver: Within this directory, create a file called
AutoChromium.desktop:
git clone https://github.com/adafruit/
Adafruit_Python_DHT.git /tmp/dht sudo nano AutoChromium.desktop
cd /tmp/dht
sudo python setup.py install Then type in the following:
Now clone the PiFan GitHub repo with the [Desktop Entry]
following command: Type=Application
Exec=/usr/bin/chromium-browser --noerrdialogs
git clone https://github.com/ --disable-session-crashed-bubble
jeroenpeters1986/piFan.git /home/pi/pifan --disable-infobars --disable-translate
--kiosk http://127.0.0.1
All software needed will now be on the Raspberry Pi. Hidden=false
X-GNOME-Autostart-enabled=true
>STEP-05 Name=AutoChromium
Configure the software
We now need to configure the software we just Now save the file and reboot the Raspberry Pi, so you can
downloaded. The following commands will configure see if it worked.
the web server and create three processes that will be
supervised (so they are always available): >STEP-06 SHUT IT
Customise your PiFan DOWN
sudo rm /etc/nginx/sites-enabled/default If you know a thing or two about HTML and CSS, and CORRECTLY
cd /home/pi/pifan/config a little bit about JavaScript, you can customise the
Tap the fan-
sudo cp nginx-sites-enabled-default interface yourself! There is only one HTML file you guy in the
/etc/nginx/sites-enabled/default can edit. In there, you’ll also see the JavaScript and top-left and
sudo cp supervisor-* /etc/supervisor/conf.d/ CSS references. To customise the PiFan touch interface, the PiFan text
is highlighted.
edit the /home/pi/pifan/webinterface/index.html Tap this text
The last requirement is to autostart Chromium with file. Once you have made changes, tap the refresh to engage
the interface. Create the autostart folder and change button on the top-right of your touchscreen to see a proper
shutdown.
directory to it: your changes.
USING PYTHON
great house
> A keyboard
can run again and again to make as many copies of your Co-ordinates in Minecraft
design as you want. You never need to worry about your Let’s start with a review of the co-ordinate system
creation being destroyed by your brother or sister ever that Minecraft uses to know where to place blocks.
again when you can simply rerun your program and get If you are already familiar with this, you can skip to
it back. Whilst it might take a little longer to write the the next section. Otherwise, read on.
house-complete.py
#!/usr/bin/env python3
from mcpi.minecraft import Minecraft
from mcpi import block
# Connect to Minecraft
mc = Minecraft.create()
width = 5
height = 3 Figure 3 The house now has a door and cobblestone
floor. It is already possible to walk inside
depth = 6
# Add a Door.
mc.setBlock(x+1, y, z+3, block.DOOR_WOOD.id, 0)
mc.setBlock(x+1, y+1, z+3, block.DOOR_WOOD.id, 8)
# Add Windows.
mc.setBlocks(x+3, y+1, z+3, x+4, y+2, z+3, block.GLASS.id)
mc.setBlocks(x+2, y+1, z+3+depth, x+3, y+2, z+3+depth, block.GLASS.id)
mc.setBlocks(x, y+1, z+5, x, y+2, z+7, block.GLASS.id)
mc.setBlocks(x+width, y+1, z+5, x+width, y+2, z+7, block.GLASS.id)
# Add a Roof.
for i in range(int(width/2) + 1):
mc.setBlocks(x+i, y+height+i, z+3, x+i, y+height+i, z+3+depth, block.STAIRS_WOOD.id, 0)
mc.setBlocks(x+width-i, y+height+i, z+3, x+width-i, y+height+i, z+3+depth, block.STAIRS_WOOD.id, 1)
# Gable ends.
if (int(width/2) - i > 0):
mc.setBlocks(x+1+i, y+height+i, z+3, x+width-i-1, y+height+i, z+3, block.BRICK_BLOCK.id, 0)
mc.setBlocks(x+1+i, y+height+i, z+3+depth, x+width-i-1, y+height+i, z+3+depth, block.BRICK_BLOCK.id, 1)
change the values once the house is complete and you We have to work out the values that we need to use in
want to alter its design. place of x1, y1, z1, x2, y2, z2 for our walls. Note that what
It’s now time to start placing some bricks. We we want is a larger outer block made of bricks and then
create the shell of our house with just two lines of to fill it with a slightly smaller block of air blocks. Yes, in
code! These lines of code each use setBlocks to create Minecraft even air is actually just another type of block.
a complete block of bricks. This function takes the Once you have typed in the two lines that create
following arguments: the shell of your house, you should run your program.
Before doing so, you must have Minecraft running
setBlocks(x1, y1, z1, x2, y2, z2, block-id, data) and displaying the contents of your world. Do not
have a world loaded with things that you have created,
x1, y1, z1 are the co-ordinates of one corner of the as they may get destroyed by the house that we are
block of bricks that we want to create; x2, y2, z2 are building. Go to a clear area in the Minecraft world
the co-ordinates of the other corner. The block-id before running the program. When you run your
is the type of block that we want to use. Some blocks program, check for any errors in the ‘console’ window
require a further data value; we will see that being and fix them before continuing trying to run it again
used later, but it can be ignored for now. until all the errors have been fixed.
Figure 4 The
windows have
been added on
all four sides
CODING GAMES
ON THE RASPBERRY PI
IN C/C++ If coding is about manipulating data, let’s manipulate some data
PART 04
You’ll
Need
he graphics in our game so far are nice, but a of Cartesian x-y co-ordinates, which represent pixels
T bit simple and fixed. Also, we only have one
graphic. This can be easily fixed by making our
in that space.
Another slight issue is that our ‘squares’ are not
> Code::Blocks CPU do what a CPU is designed to do, which makes actually square – they are rectangular. That’s because
sudo apt-
get install our life a lot easier. We also need to try to make the our concept of -1.0f to +1.0f is considered to be a ratio
codeblocks creation and use of graphic objects easier and more of each axis of the clip space, which we set to be a
> STB flexible. Let’s begin. rectangular size when we defined our screen sizes.
magpi.cc/ We mentioned last time that all programming Our images also use those ratios, so they become mini
2GCQe19 is about manipulating data based on conditions or rectangles like the screen.
> A pretty picture; needs. Let’s consider a possible need we have and So it’s clear we need to do something to turn these
not too big
think about how we can manipulate the data. ratio values into simple pixel co-ordinates and get rid
At the moment we move our squares based on of this rectangular distortion.
values -1.0f to +1.0f on the x and y axes. This gives We have to keep in mind that our GPU thinks in
READ us a rather cumbersome way of working out their terms of clip space, so when it draws, it will need
THE CODE
position on the screen; we can only really be sure to use a clip space value. If ‘we’ want to use pixel
There are of the centre 0,0 position and the edges. This is all co‑ordinates, we have to transform them into ratios
comments and because of the way our GPU thinks about the buffer for the GPU to use.
descriptions in
the code that it draws graphics in, called the clip space. For a So we have a need: we want to use pixel
explain what GPU, it makes sense to use a value that represents a co‑ordinates and turn them into clip-space ratios
it is supposed ratio of the size of its clip space buffer; for a human, when the GPU wants to use them. There are actually
to do.
though, we’re much more comfortable with the idea two ways to do this. We can do it in our draw code
before we send the position value to the shader, using
quite a simple sequence of steps; or, even cooler, we
can do it in the shader itself.
Which is best? Well that’s a really good question,
because both systems will work. Ideally, we want to
make it happen on the shader, because shaders love
doing maths. To begin with, let’s do it on the CPU so
we can be very sure about what is happening.
NAME:
MagPiHelloTriangle.
cpp,
SimpleObj.h/cpp,
Game.h/cpp,
OGL.h/cpp
DOWNLOAD:
magpi.cc/PryrsN
Here, all we want to do is turn a pixel value that is Figure 2 Nice and square
easy for us to understand into a ratio that is easy for here we run into a bit of a quandary. Yes, we can do it
the GPU to understand. This is a case of using the in our CPU code, but if we’re trying to change data we
pixel values and sizes we have and seeing them as send to the shader, wouldn’t it be better if the shader
fractions, which then become ratios. We have a slight changed the values?
complication since the clip screen uses co‑ordinates Well, the answer is probably yes, but it does mean
between -1.0f and +1.0f, and we really want to remove we need to make changes to our shader, and pass
negatives. However, we know the width and height of information that allows it to convert screen-based
our screen, so in our update we can do this: co-ordinates to ratios.
We know we pass information from code to
Pos[0] = ((Xpos-512) / 512); the shader in uniforms, as we did with the ratio
Pos[1] = ((Ypos-384) / 384); co‑ordinates. Let’s try sending info on the screen
size, by modifying the shader and changing our
Subtracting half the screen height or width, and
then dividing the result by that half value enables us
to move our co-ordinate systems to a bottom-left
There’s no escaping the fact
position: 0,0. that manipulation of almost
Now we can code that in our draw function, and
change our initialise and update systems to work on any data is maths
real pixel values instead of ratios. So, rather than
test for -1.0f and +1.0f, test for 0 and SCREENWIDTH uniform send systems to pass position and Screen
for the x direction, and 0 and SCREENHEIGHT Size data. Check out the new shader in the code for
for the y direction. this lesson: magpi.cc/PryrsN.
Try to make the changes in Lesson 3’s code, Now when we run these we get nice square objects,
use co-ordinates in your update code, and convert but there’s one last thing we want: the ability to
before the draw sends to the shader (you will also dictate their size.
find it on the GitHub: magpi.cc/2suLVC2). You can As our The MagPi logo was quite large, our current
see we are bouncing around still, but now we have triangle vertices are actually 0.1f offsets. This means
a much easier-to-understand co-ordinate system they are already one-tenth their natural size, but we
which allows us to think in pixel terms rather than might want to have them be any size. This is called USE GOOD
ratios. Our needs have been partially resolved; we scaling, and again it’s best done in the shader. We TOOLS
still have our oblong shapes and another niggle: now need to pass three things to the shader: the
We’re about
they’re the wrong size! co‑ordinates (as x and y pixel values), screen sizes, to make a 2D
and a scale value. tile game, so
How to make it better Now, that is starting to sound like a lot of data find a good
tile editor:
To fix the oblong issue, we also need to change the to send, and it is. We can live with it for now, but mapeditor.org
ratio-based offsets that make up the triangles, and ideally we should try to organise the data in a better
UPGRADING
assuming you have the correct libraries installed to
run them of course. All the tutorials and projects
TO A NEW PI
you’ll find in past issues of The MagPi and on the
Raspberry Pi website will continue working with
a new Pi model.
Similar hardware
HATs will still work on newer Raspberry Pi boards,
SHOULD I UPGRADE MY so you’ll just need to transfer over any relevant
RASPBERRY PI? configuration files to get them running. The new
PoE HAT, though, is designed specifically for the
Want versus need new Pi 3B+, so you won’t get it working on a Pi B+
If you’re happy with your or a Pi 2.
current Raspberry Pi, there’s no
immediate need to upgrade. Most Same Raspbian
tutorials and projects are made The Raspbian operating system is used across all
to be used with any Pi model, Raspberry Pi models, so there shouldn’t be any
and the updates to Raspbian will confusion or need to learn new stuff when getting
continue to be made with every a new Pi. All the same software and such will also
Raspberry Pi in mind. be available on newer hardware.
Newer is better
That being said, newer Raspberry WHAT SHOULD I DO WITH MY OLD
Pi models (such as the 3B+ in RASPBERRY PI?
this issue) have performance
improvements over the previous Put it to work in the house
versions. The extra power or If you fancy putting together a file server or finally
connectivity options might help solve an issue you’d creating a Kodi box or retro games console, now is
had in a project, or even just improve your Raspberry the time to do it since you have a spare Raspberry
Pi desktop setup. Pi. These projects are easy and quick to make,
and at least your old Pi will still be put to use.
For business
If you use a Raspberry Pi in an enterprise setting, Zero to do
newer Pi models tend to have extra functions with While the Raspberry Pi 3B+ is more powerful than a
business in mind, such as the Power over Ethernet Pi Zero, the Zero’s size makes it much more suitable
(PoE) pins and PoE HAT coming to the Pi 3B+. Like for smaller projects, so don’t count it out yet. Keep
any new bit of tech, it’s worth researching to see your Pi Zero for projects that could use it over a
if it would aid your company. bigger and more powerful Pi.
At SB Components we strive to offer our customers the best prices for the best products. Our product team works
tirelessly to source top quality affordable components from around the world. Raspberry Pi is a trademark of the
Raspberry Pi Foundation. Raspberry Pi not included.
Feature
E T O T H E O L Y M P I C S
W E L C O M O B O T S
O F R A S P B E R R Y P I R
he Raspberry Pi has helped revolutionise
2014
The obstacle course
T many things. From computing education,
to the maker community, and even how
for the first Pi Wars you play games at home, the Raspberry Pi has
was much simpler
had a huge impact. It’s also helped change the
face of hobby robotics, making it more accessible
than ever before.
To celebrate this renaissance of robotics, the
organisers of the regular CamJam event hold a yearly
contest known as Pi Wars that pits the Raspberry Pi
community’s best automated efforts against each
other. There’s no fighting, though: the robots take
part in devious challenges designed to test how well
they’ve been built and programmed, and at the end
of the day they get to be taken home in one piece!
Most of the time.
This year, over 70 teams are taking part over two
days. Here’s what you can expect from the event.
HOW TO BUILD
A ROBOT
WANT TO ENTER PI WARS? YOU’LL NEED A ROBOT THEN…
YETIBORG V2
> £160 / $220
magpi.cc/TADbiy
From the robot CAMJAM EDUKIT 3
DEXTER INDUSTRIES boffins at PiBorg, > £18 / $25
dexterindustries.com the new version magpi.cc/tNKkmk
Dexter is a hobby robotics specialist, of the YetiBorg is built to A great, classic starter kit, the
with a number of kits and sensors run on a Raspberry Pi Zero. It’s CamJam EduKit 3 comes with the
and such made specifically for small, powerful, and extremely basics for making a robot. You’ll
the Raspberry Pi. You can buy its well put together, much like need to add a Raspberry Pi and
products from ModMyPi in the UK. the other PiBorg offerings. The chassis – although you can always
ZeroBorg motor controller it use the box for the latter! It’s a very
comes with lets you add standard simple robot, but it does teach the
analogue sensors, and can be basics and has decent parts that you
daisy-chained too. can use when building your robot.
PIBORG FORUM
magpi.cc/RmbMDY
CAMERA The PiBorg forum is a great place to ask about
SEE THE WORLD PiBorg kits. The team behind them are experts at
magpi.cc/28IjIsz INFRARED robotics as well, so they should be able to help you
With a bit of skill, and a lot of help ANOTHER RANGE FINDER with any query.
from the OpenCV software library, magpi.cc/rVRhwP
you can get a Raspberry Pi robot Depending on material, an infrared
to react to the world around it. It’s range finder can be more accurate
mainly used for differentiating than an ultrasonic one. However,
colours, but OpenCV is very they don’t work so well outdoors.
powerful and can do more. Luckily, Pi Wars is an indoor event!
RASPBERRY PI FORUM
raspberrypi.org/forums
The Raspberry Pi community are always happy
to help someone in need. Give the forum a search
MICROSWITCH first to see if any of your questions have already
SENSITIVE BODY been answered.
SENSORS
magpi.cc/vywZnT PREVIOUS ISSUES
Some simple robot kits make use of OF THE MAGPI
microswitches to figure out when We’ve done robot tutorials
they’ve hit a wall. Classically, the in the past – including a
robot will then turn away from the guide on how to make and
wall, but you can always add one upgrade one in issues 51
as a shut-off switch for a straight- and 52 respectively.
line speed test magpi.cc/issues
HOW WINNERS
BUILD THEIR ROBOTS
HERE ARE SOME OF THE TOP ROBOT TEAMS FROM PAST PI WARS – WHAT HELPED THEM WIN?
TRACTORBOT
One of the unique features of
TractorBot was the interchangeable
noses for different contests – for
CONTEST: PI WARS 2014 example, for the golf game they
WINNER: UNDER £75 used an extended nose that would
BUILDER: IPSWICH MAKERSPACE keep the ball rolling ahead of the
robot. Unfortunately, while good for
One of the first winners of Pi Wars, keeping the ball under control, it did
the TractorBot was made out of not help to release the ball through
laser-cut wood and created by the the hole. They were also able to add
folks at Ipswich Makerspace, who pipe insulation for the sumo contest
are veterans of the competition. to soften impacts on the robot.
OF PYROBOT
which unfortunately did not place.
However, he came back stronger in
2015 with the Revenge of PyroBot.
CONTEST: PI WARS 2015 “My robot Revenge wheel
WINNER: LARGER THAN A4 layout was inspired by PiBorg
BUILDER: BRIAN CORTEIL DiddyBorg kit layout,” said Brian.
“I built the chassis in a weekend
Brian Corteil should be and was driving it on the Sunday
recognisable to readers of the mag evening. The rest of the robot BRIAN’S
– he wrote our feature on building
a robot in The MagPi #51, which
was added over the following
months, with the final design put
ADVICE:
Build your base
was then further developed into together on the Friday evening early. Drive it at
least a couple of
the Tiny 4WD. He entered the first before Pi Noon!”
hours, two days
a week.
EXABOT
– along with a lot of training to get
to grips with some of the challenges
awaiting at Pi Wars.”
CONTEST: PI WARS 2017 While of course the robot build is
WINNER: SCHOOLS AND KIDS CLUBS very important, training and testing
BUILDER: TEAM EXABOT should not be overlooked. The ExaBot
team even went as far as building
“Our team built a completely custom their own maze to tweak their
robot for this year’s competition,” the software at the last minute, finding
team wrote on their blog. “Working some issues they were able to account
on everything from the core electrical for before the big day. Still, issues
and mechanical design to the Python were found during the challenges, so
program used to operate the robot you can’t account for everything.
MR BIT
with he and Rebelle learning as
they went. Simpler solutions were
found in favour of going over the
CONTEST: PI WARS 2017 top, including one involving the
WINNER: BEGINNERS use of multiple distance sensors
BUILDER: BROUGHTON FAMILY for the maze, and a simple claw/
mandible design controlled by
Tom Broughton and his daughter motors for manipulating the ball
Rebelle had never built a robot before, in the golf challenge.
but that wasn’t going to stop them “Very naively we assumed it
from entering Pi Wars – after all, it would be a very simple task to put
did now have a Beginners category. a robot together,” Tom admitted.
You can follow the very careful “But we soon realised, as mentioned
progress of building the robot on in many of our posts, what a huge
Tom’s blog (digitalpolymath.co.uk), underestimation this was.”
STEVE
months before the April 2017
Pi Wars event, going through
different controllers as the robot
CONTEST: PI WARS 2017 was built and tested. In the end,
WINNER: INTERMEDIATE Steve ended up being a modest
BUILDER: TEAM STEVE robot, running off a Raspberry Pi
Zero and an Arduino, and using a
Steve is not a fancy acronym (or Dagu chassis and speed controller.
backronym?) like KEITH, but is Despite this, it managed to win the
instead just a robot called Steve. Intermediate category and even
A robot that looks like a dog. came first in the golf challenge. PI WARS
Steve had been in the works for Good boy, Steve! CATEGORIES
PI WARS 2014
MAX
exception, especially compared to
the balancing two-wheel robot he > Under £75
had originally planned for the 2017 > Over £75
CONTEST: PI WARS 2017 competition (hence the team name).
WINNER: ADVANCED/PRO Compared to the Tiny and the PI WARS 2015
BUILDER: 2 WHEELS OR Tiny 4WD, Max has an additional > Larger than A4
NOT 2 WHEELS series of distance and line sensors > A4 and smaller
and a more custom chassis. While
Brian Corteil came back to Pi Wars it didn’t do particularly well in the PI WARS 2017
last year with another winner in automated events, Brian’s tactic > Schools and Kids
Max, based on the Tiny robot that of practising his robot control paid > Clubs
was originally built for The MagPi! off, with him placing highly in (and > Beginners
Brian is great at building powerful, even winning two of) the manual- > Intermediates
sturdy robots and Max is no control events. > Advanced/Pro
HOW TO CONQUER
THE CHALLENGES
THE EVENTS AT PI WARS TEST THE BUILD QUALITY AND PROGRAMMING SKILL BEHIND EACH ROBOT.
CO-ORGANISER MICHAEL HORNE REVEALS THE TASKS THEY NEED TO CONQUER
A shallow trough 7.3 m (24 feet) together. While it seems like it will Don’t let this simple-looking maze fool you: this
long comprises the course for the be simple, any robot maker knows can be quite tricky for robots as you’re not allowed
speed test. Your robot needs to that very few robots go in a straight to help them, and they’re not permitted to touch
traverse this course autonomously line without some coding help. any walls.
as fast as possible, without hitting The concept behind this maze is for your robot to
the sides. The course is usually OFFICIAL TIP: It’s important sense the different colours that are painted on the
534 mm wide, but there are to get a balance between being wall to inform how it navigates. Programming your
sections where it will narrow. as fast as possible and being robot to turn while seeing certain colours, and only
With a white line down the centre as accurate as possible – we’ve moving so much at a time, is key to navigating the
which you can use for navigation, added chicanes which count maze successfully. While slow and steady can win
the course will be run three times as ‘walls’ which incur penalties the race, the event is
and the scores for each run added when touched. measured on completion
time, so don’t dawdle.
OFFICIAL TIP:
There are so many
ways to do this, but
we’ve allowed the
SOMEWHERE OVER THE RAINBOW addition of ‘markers’ on
YOUR ROBOT NEEDS TO FIND AND TOUCH A SERIES the course which might
OF COLOURED BALLS, PREFERABLY IN SEQUENCE be an easy way to
orientate yourself if you
Robots are placed at the centre of a by 122 cm, and the black walls use ‘vision’ to navigate.
square arena in this new challenge. are 300 mm high. At each corner
The wooden arena measures 122 cm there’s a coloured ball suspended
100 mm off the floor of the box.
Your robot must visit each ball a maximum of three attempts,
once, and they can do that in any with their fastest attempt used
order, or shoot for more points and for scoring.
go in the predetermined order of
Red, Blue, Yellow, and Green. OFFICIAL TIP: We’re supplying
The kicker? Each ball’s a calibration or ‘try out’ course in
placement will be random for each addition to the ‘real’ course – use
team, so the robot truly has to look it to get your sensors in shape
for the correct colour. Contestants before the real runs.
have seven minutes to perform
REMOTE-CONTROLLED
CHALLENGES PI NOON
BURST YOUR OPPONENT’S
BALLOONS USING SUPERIOR
MOBILITY AND TACTICS
RASPBERRY PI
PROJECTS BOOK
Amazing hacking and making projects
from the makers of magazine
Inside:
How to get started coding on Raspberry Pi
able
Availw
no magpi.cc/store
plus all good newsagents and:
MATRIX
VOICE
A voice-recognition board featuring an LED loop and
eight-mic array. Phil King has a few words with it
Related
In essence, the Matrix Voice Pi before being set free to function access the Raspberry
is a slimmed-down spin-off of as a standalone device. The most Pi’s GPIO pins directly.
Matrix’s original Creator board. visually impressive aspect of the
AIY
VOICE KIT Whereas the Creator was crammed Voice is its circular ‘Everloop’ array Many voices
with all sorts of sensors, and of 18 RGBW LEDs. As well as the One of the key plus points of the
Google’s
cardboard Voice is its compatibility with
kit for voice
recognition Compatible with a wide range of a wide range of voice assistant
platforms, including Amazon
voice assistants, including Alexa
includes a
mini speaker Alexa, Google Assistant, and
and two-mic PocketSphinx. Disappointingly,
array, while
its Voice HAT
and Google Assistant however, getting started with the
board features device is made more difficult by
connections other bells and whistles, the Voice ability to display cool light patterns, the lack of helpful, Voice-specific
for servos
focuses on voice recognition. To this can provide useful visual information on the matrix.one
and motors.
this end, it retains the array of feedback during voice interactions. website. A lot of the documentation
eight digital MEMS MP34DB02 Near the middle of the board, as and examples are related to the
microphones, although here on the Creator, is a square hole for Matrix Creator, and the Voice data
they’re arranged differently: seven mounting a Camera Module if you sheet only offered links to a couple
placed at regular intervals around wish. Elsewhere, a 24-pin female of tutorials. Matrix tells us it is
the perimeter and an eighth in expansion header is connected to working on creating additional ones
the middle. Audio processing – the FPGA to connect and control and improving the documentation.
£25 / $25
including noise cancellation and electronic components, but (testing Following the Alexa step-by-step
magpi.cc/AWeXwv
de-reverberation – is handled by it with a basic LED circuit) we were guide (magpi.cc/Wzovwo) took
FREE
Maker
Says
Files on
demand for
everyone
Make Mark App
MAKE MARK
APP BETA
Rob Zwetsloot investigates a different way of linking
Dropbox to Raspberry Pi using middleware
ropbox has never been very creating folders on the Raspberry on making it better. Instructions
D well supported in Linux.
Raspbian has it even worse
Pi, setting up folders on Dropbox,
and making it launch at boot. You
and documentation are provided
in somewhat broken English,
than standard flavours of Linux. In can then log in to Make Mark from although they’re easy enough to
SUBSCRIBE AND
SAVEUP
TO
35%
on the cover price
ISSUE #05
£15 / $20
Maker
Says
NES case
specifically
designed for
Raspberry Pi
3, 2, and B+
Kintaro
NES CASE
Rob Zwetsloot plays with power as he turns his Raspberry Pi
into a mini NES with the Kintaro Entertainment System
ases for the Raspberry Pi the halves together from below. system. However, even with the
C are a dime a dozen these
days, so it’s nice to see
Job’s a good ’un. ‘vents’ on the side of the case,
accessing the GPIO pins is tricky,
people selling fun themed cases Flip the flap and putting a camera cable through
for your Pi projects. It sets them While on the original NES the the USB flap isn’t ideal. While the
apart from the myriad plastic, controller ports were located on case was not designed with this in
yet functional, cases for the the front of the machine, the USB mind, it’s worth mentioning in the
Raspberry Pi. ports on the Raspberry Pi aren’t event that you were planning to
The maker of this case, Kintaro, quite arranged like that. In a rather use this as your only case.
sells a couple of retro-console-
themed cases. Along with this
Useful for using a Raspberry Pi
Related NES-inspired case, you can also
get a (US purple) SNES-style as a standard computer
case. The NES one is smaller and
OFFICIAL
RASPBERRY simpler than the SNES version, or a retro gaming system
PI CASE but still functions as a proper
A more versatile Raspberry Pi case. ingenious move by Kintaro, the
case. While it
does look cool,
Putting a Raspberry Pi in the cartridge flap has been recreated Last word
it may not quite case couldn’t be easier – the two on this case – simply flip it up to
be NES cool. halves come unfastened in the gain access to all the USB ports and
A great, simple case that might
be good for your home media
box so you can separate the two. the Ethernet port. Otherwise, all
setup if you’re missing the
Inside you’ll find four screws and a the important ports and slots are
elusive NES Classic Mini. Don’t
couple of heat sinks in bags which accessible while the Raspberry Pi is
get it for hacky electronics
you’ll need to remove. Place the in the case, even the microSD slot.
projects, though.
Raspberry Pi inside the bottom The case is really useful for
£6 / $10
half, replace the top half, and then using a Raspberry Pi as a standard
magpi.cc/ppUaBN
use the provided screws to secure computer or a retro gaming
CRACKING CODES
RASPBERRY PI WITH PYTHON
working up to more advanced
Python topics. Python’s strengths
BESTSELLERS
at data handling make this
sort of thing fairly painless,
Author: Al Sweigart
and (relatively) few external
MANGA MATHEMATICS
Publisher: No Starch
Price: £25.50 libraries are needed, so the
ISBN: 978-1593278229 beginner can stay fairly focused
No Starch’s Manga guides use manga magpi.cc/WiQljD on learning coding, not stacking
storytelling to make difficult subjects together modules.
surprisingly approachable Yes! A book that Complete code listings are
teaches Python given early in each cipher sample,
CLEAN C++
& Shin Togami
Publisher: No Starch not just a restatement of best
Price: £15.99 practices laid down in many
ISBN: 978-1593271947
Java books, but as it goes from
magpi.cc/moKUBC Author: Stephan Roth
Publisher: Apress the general to the specific, the
A lovely attempt at tying calculus Price: £29.99 many C++ examples illustrate
into its real-world applications, ISBN: 978-1484227923 how relatively simple (and
from an economist with a strong magpi.cc/LlKCOy ultimately beneficial) it is
appreciation of the subject.
Perhaps best used in tandem to incorporate the practices
with a dryer and deeper textbook C++ projects seem into your own code. Roth is an
or MOOC, but it will make either
more prone than opinionated commentator – but
much clearer.
most to delivering generally in a good way – and
PRODUCT
Publisher: Wiley
deliverables, but in terms of your
Price: £21.99
organisation’s values, and where
ROADMAPS
ISBN: 978-1119014874
you want to make life better for magpi.cc/TCyZow
RELAUNCHED
your customers?
If this all sounds a little vague, Not in any way dumbed down – a
brilliant guide to sprites, animations,
good. A roadmap is a
comics, programming, and plenty of
Authors: C. Todd Lombardo, strategic document, games. And really good fun.
Bruce McCarthy, Evan Ryan, not a product plan.
& Michael Connors
Publisher: O’Reilly
To make it more Learn to Program with Scratch
Price: £27.99 concrete, the book Author: Majed Marji
ISBN: 978-1491971727 moves from the why Publisher: No Starch
magpi.cc/AKZhOp to the how – to make Price: £27.99
ISBN: 978-1593275433
a flexible roadmap
magpi.cc/KjPpaU
What is a product roadmap? An that can be shared
out-of-date listing of deliverables? with your customers, without Truly excellent introduction to more
A best-fit compromise that promising anything that would formal programming concepts,
using Scratch, for beginners or
doesn’t really satisfy any of your skew the product away from where
experienced Scratchers.
stakeholders? A source of contention it should be going. This product
within your organisation? A bright we talk of could be an IoT project, Cool Scratch Projects
shiny vision of the future that your app, or website – but the advice in easy steps
customers don’t trust? Roadmaps carries over into many other Author: Sean McManus
have failed to keep up with agile fields. A thoughtful and thought- Publisher: In Easy Steps
development, and are often mired in provoking re-examination of one Price: £10.99
detail best put in a project plan. of the fundamentals of building a ISBN: 978-1840787146
magpi.cc/2me3yQu
Product Roadmaps Relaunched takes successful IT company.
a fresh look, removing focus from Magic Mirror, 3D effects, using the
deliverables, and looking at the why. Raspberry Pi’s Camera Module – there’s
Where’s the product going – not in Score plenty here for any Scratch learner to
move onto as the next step.
set-in-stone phases of promised
In general you can find all kinds The entire idea of the project was
of electronic music, although every to use only Pi 2 and nothing else. I
song is different: from electro/ composed this music on the Pi and
techno-pop, through Eurodance, then recorded it all directly from the
to instrumental electronica [a bit headphone output of the board.
like] Mike Oldfield. It then ends in a The Pi 2 is powerful so the
chiptune style with BitPusher2600’s songs can be complicated and use
remix made on the Pi. multichannel, which makes for a
great tune for the listener. The most
Why a Raspberry Pi? complex song on the album consists
I bought one when the Pi 2 was of 26 independent channels of digi-
Yerzmyey
still the new model. However, my music. The Pi can surely manage
decision back then was motivated more, but that wasn’t the point of
directly by the announcement that this album.
Occupation: Musician the Raspberry Pi outsold the ZX
Spectrum. I thought, “Aha! I have How did you go about composing
to get one NOW!” The Raspberry the album?
aking music on a Raspberry Pi, being a British computer, is I programmed all notes one-by-
M Pi is simple enough thanks
to Sonic Pi. However,
important to me as I’ve been a
ZX Spectrum fan and user since
one, as is customary on the music
trackers. You have to put all the
demoscene musician Yerzmyey the eighties. notes/sounds in manually without
decided to go one step further and The Pi is a modern, and potent, any automatic help. Otherwise I
make an entire album using the machine. Obviously, it’s not old use loops, but only when it comes
Raspberry Pi as his instrument. You school, but you can feel some cool to drum ‘n’ bass music (drum loops
can listen to RPi ZWEI here while old-school philosophy behind it. are indispensable there) or when I
you read through our interview with
him: magpi.cc/WhekCf.
play the guitar (or ask some friends 1-bit music on ‘Wham! The Music Above Made on mention it’s much cheaper, smaller,
a Pi 2, the RPi
to do it for me; I’m not a very good Box’ and after that I changed to ZWEI mini album
cuter, and far more portable).
guitarist). I cut these recorded SoundTracker 1.1 and the AY chip. features five tracks Text editing, spreadsheets,
guitars into loops and put them Since then I’ve made music internet with YouTube included,
into the song/module in a form of for over 60 games, mostly for ZX music listening, watching movies,
WAV files. Of course, the multilayer Spectrum; sometimes with such and stuff like that. I also do a lot of
technique is useful there too, so distinguished ZX game-developers gaming, mostly using RetroPie.
I can ‘play simultaneously’ on like Jonathan Cauldwell – and many I have my PC and the Pi
many guitars. other, equally talented friends. permanently connected into one
My weapon of choice on the I participated in making numerous switchable monitor so I don’t have
Raspberry Pi is MilkyTracker, a demos for Spectrum and Atari ST – to buy a second PC, as the Pi is
familiar and powerful tool. Of course and played many chiptune concerts totally enough. Ten years ago this
the Pi can do a lot, so for example in various places on planet Earth. was unthinkable. They weren’t
one can use emulators or cross- called towers for nothing.
platform trackers to make chiptune How long have you been
music too. I tested how the SID chip making music? Do you plan on making more music
emulation works on the Pi 2, with I remember making songs for our with Raspberry Pi?
the GoatTracker, and it is really group’s first demos and games Actually I do. Of course, every time I
nice: magpi.cc/lrJKai. in 1987 – games like Ghost Eater try to make some new stuff, so this
There’s other software of course; (1987) andHunting (1988) – but I time I was considering buying and
for instance, there is Unreal Speccy don’t think they exist any more using the Raspberry Pi Zero for a
Emulator for ZX/AY lovers and so (everything was recorded on tapes change. A smaller machine, more
on. There’s also really complex in those days) so the earliest demo limited – it might be interesting. I
software-synthesizers that you can I still have containing my chiptune will try, presumably.
use – you can find out more info attempts comes from 1989 and my Another thing would be to make
about them here: magpi.cc/YUXfeE. first game music (a text adventure) something for the Pi 3, but it’s so
comes from 1993. powerful that probably I would have
Do you have a background in to make – I don’t know – some
chiptune music? Have you used the Raspberry Pi for symphonic music on it? Which
For chiptune stuff I mostly use a ZX anything else? might be tricky because last time
Spectrum 48K with AY-interface, Like I mentioned before, the Pi is I tried that was in the ‘90s. Also,
although when I started in the late a powerful machine so I use it for trackers aren’t very good for this
eighties, there was only BEEPER literally everything. It’s as useful as particular kind of music (MIDI is
accessible, so initially I was making any other modern computer (not to better here). But we will see. Or hear.
THE MONTH IN
RASPBERRY PI
Everything else that happened this month in the world of Raspberry Pi
BIG BIRTHDAY
WEEKEND!
OVER 100 JAMS CELEBRATED
RASPBERRY PI’S SIXTH BIRTHDAY!
elebrations for the Raspberry Pi’s birthday have
C been getting bigger every year, and this year
was the biggest yet! Over 100 Jams around the
world organised a special event to honour the Raspberry
Pi on its sixth birthday, and even despite the snow in the
UK, the world was abuzz with Pi love.
Lagos, Nigeria
While fun, some serious learning
went down at the party Jams
Tokyo, Japan
The photo booth project Southend, UK
made for Pi parties was a This one was a bit closer to home as young
huge hit around the world! makers got to grips with the Sense HAT
SNOWED IN!
Unfortunately, a few Jams had to be postponed due
to the ridiculous snow the UK experienced in March.
Many Jams will be rescheduling though, so keep an
eye on your email and social media feeds!
India
Hacking about with Raspberry Pis
under a very fetching blue light in India
RASPBERRY PI 3B+
IS HERE!
A
new Raspberry Pi is always cause for a mini-
celebration, even if we’ve just celebrated a
birthday! Launched on Pi Day (14 March or, in
The community reacts
to the latest version of
the Raspberry Pi
Want to learn
American notation, 3/14) the Raspberry Pi 3B+ is the more about
ultimate version of Raspberry Pi 3. Here are some of
the Pi 3B+?
the reactions from the community to the news…
Check out our
launch video:
magpi.cc/GqePcN
KICKSTART THIS!
Raspberry Pi projects you can crowdfund this month
KITCHEN
INFOBOARD
Infoboards seem to be the
new hotness over on the
Raspberry Pi subreddit –
sort of like a magic mirror
but without the mirror part.
magpi.cc/QZTsox
CASSETTE
GAMES
CONSOLE
HACKABLE RASPBERRY Following the trend of
COMMUNITY
PROFILE
AMANDA
HAUGHS
Meet Amanda, US-based teacher, Raspberry Pi
Certified Educator, and maker of things
Amanda A
manda Haughs works as
the Digital Innovation
teacher on special
Lesson Resources, and fun projects
at home, she’s on the right track to
be making a big difference, both in
Category: Educator assignment (ToSA) for Campbell her district and across the USA.
Day job: Digital Innovation ToSA Union School District in San Jose, Amanda took part in the second
California. Within the role, she Picademy cohort to run in North
Website: twitter.com/mshaughs
works to support teachers in America. Picademy, the two-
magpi.cc/hGVavU
engaging their students, exploring day training course run by the
how to create “meaningful Raspberry Pi Foundation, provides
Below Amanda works
and relevant cross-curricular free professional development
as teacher on special
assignment within her learning experiences.” for educators, both in the UK
school district to support
On her website, Amanda and North America. A week after
educators in broadening
computer-science describes herself as “passionate the event, as Amanda recounted
skills through cross-
about the integration of technology her experience on her blog, she
curricular experiences
and computer science education in was quick to admit that her head
Below right Amanda joined
elementary classrooms to support was “still spinning with all the
Raspberry Pi Foundation
staff members Carrie the development of creativity, Raspberry Pi goodness” she was
Anne Philbin and James
critical thinking, and problem- able to obtain over the weekend,
Robinson, alongside fellow
Picademy alumnus Nicholas solving skills in students.” And and she has since gone on to help
Provenzano, on the Digital
with her continued efforts to create in further sessions of the training
Making with Raspberry Pi
panel at ISTE 2017 content such as her STEAM and CS across the country.
HIGHLIGHTS
magpi.cc/WxKuaD
In her role as Digital Innovation ToSA,
Amanda works with schools and
STEAM AND CS
educators within San Jose’s Campbell LESSON RESOURCES
Union School District, supporting
cross-curricular learning
Amanda has created a pack of project resources to aid
educators in introducing cross-curricular coding into the
classroom within her district. Once news of them made
More recently, Amanda has way to incorporate the use of my
its way to Twitter, educators across North America were
continued to integrate the use of grandmother’s hi-tech embroidery
adding them to their classroom toolkit.
Raspberry Pi into the classroom, machine,” she explains in her
working alongside fellow blog post for the project. “Right
ToSA Misty Kluesner to create away I thought it would be fun to
multimedia art projects based on embroider the Raspberry Pi logo
the theme of Awe and Wonder, and from there I realised that a
and the Aurora Borealis. This tote bag would be the way to go
exploration took the coding practice for my first wearable project.”
of computing classes into the arts The result was a tote bag
sector of the school, putting the A made from scratch that included
in STEAM where we are beginning the Raspberry Pi logo and
to see more and more examples of programmable LED lights. With
code in art and design. the conductive thread making up
magpi.cc/nikZJv
RASPBERRY PI TOTE BAG
Right away I thought it While planning her trips to educational conferences and
events in 2017, Amanda decided to create something
would be fun to embroider eye-catching and a little different. With a little help from
her sewing machine-ninja grandmother, she created the
Outside of her work in the outline for the logo, the LEDs
education, Amanda is a tinkerer. were connected to a Raspberry Pi
While planning her attendance Zero, and code controlled how and
to multiple education-based when they blinked as she walked
conferences and events in 2017, from booth to booth at ITSE 2017,
she decided to stand apart from the among other events.
crowd by integrating a Raspberry In 2015, she was awarded the
Pi-powered wearable into her PBS Digital Innovator Award,
wardrobe. While many wearables and followed this up in 2016 with
magpi.cc/OcglQP
hide their circuits behind folds the SVCUA Outstanding Teacher RASPBERRY PI
of fabric, Amanda decided to Award. With her Raspberry Pi CERTIFIED EDUCATOR
celebrate hers by using conductive Certified Educator pin to boot, Amanda attended Picademy in California, 2016,
thread and her grandmother’s Amanda continues to work hard, becoming one of over 400 Raspberry Pi Certified
programmable sewing machine. gaining more recognition along Educators (RCEs) so far trained in North America.
“I loved the idea of making the way, and the North American With her Picademy pin in hand, she went on to help the
something wearable and blinky, Raspberry Pi community is proud Raspberry Pi North America team train more RCEs at
and also wanted to figure out a to have her on board. future events.
FIND OUT
ABOUT JAMS
Want a Raspberry Jam in
your area? Want to start one?
Email Ben Nuttall about it:
ben@raspberrypi.org
3 RASPBERRY JAM
LOOP
Bangalore, India
8 LEEDS
RASPBERRY JAM
Leeds, UK
5 PRESTON
RASPBERRY JAM
Preston, UK
1 PI JAM!
Fab Lab, Limerick
4 PI WARS 2018
Cambridge, UK
WHAT TO DO
Where: Gartner UK HQ,
Staines-upon-Thames, UK
magpi.cc/stfIbP
Primarily a show-and-tell event
“When I ran the Manchester Jam, people were
where people bring along their
happy to work on their own projects. Occasionally
projects for others to try out and
we ran a track of talks, or put on a workshop, which
learn from.
was a nice change. Now I run the Jam at Pi Towers,
the attendees tended to be mostly beginners –
LEEDS RASPBERRY JAM usually parents with their children – so we mostly
When: Wednesday 2 May
run workshops and hand out worksheets.”
Where: Swallow Hill Community
Ben Nuttall
College, Leeds, UK
Raspberry Jam @ Pi Towers
magpi.cc/HdaaIj
There will be chances to get hands- Every Raspberry Jam is entitled to apply for a Jam
on with digital making activities starter kit, which includes magazine issues, printed
through the workshop, and a worksheets, stickers, flyers, and more. Get the
hackspace area to share projects. guidebook here: magpi.cc/2q9DHfQ
YOUR LETTERS
CATALOGUING RETRO COMPUTING
OLD ISSUES
I’m a little bit of a latecomer in the area of trying
I love the idea, and have long
wanted to do a RetroPie but…
years back I ran Sinclair QLs,
Linux (Slackware!) and onward…
meanwhile the QLs (and monitors
and floppies) sat in storage.
to read all the old issues of The MagPi. It’s a tedious and managed to get the game Now running a Core i3 with
task and I have not found a place with a list of all Stellaris, a strategy game, keyed Kubuntu and a Pi 3, with a Pi
the contents. I tried to copy-paste them from each in (laboriously, QL SuperBASIC). sitting unused, I thought ‘why
magazine but have not quite succeeded. For some This was at a time when storage not a RetroPie?’ I dug out the QL
reason, some of the magazine contents can be was by tape, basically a cassette magazine (QL World, June 1987)
copied in a reasonable manner whereas some cannot recording of the tones of the and OCRed the Stellaris program
– usually requiring some editing. phone-line modems of the day (much easier than typing it all!),
Is there a catalogue and if not could you please (perhaps 9600 bits per second ending up with a 36kB text file
make one? – a generous estimate, and yes, that includes the author’s player
Jukka Salo bits!), and before that degraded instructions… and then tried
too far I got it over to a 720kB to find a QL emulator. RetroPie
Thanks for having a go – unfortunately floppy disk. doesn’t have one.
it’s a bit of a big task! We think the best The keyboards failed and I I think there’s one in
way to get a good highlight of projects abandoned them. Meanwhile I Windows’ ‘DOS box’ system,
and tutorials and reviews is to check had already progressed through but IIRC (it was long ago) I gave
out the Official Projects Books that we IBMs: PC (180kB 5-inch floppy), up trying to get it to run. Long
release every year. The best of the best extender board, XT (360kB and short: is there a QL emulator
make it into these books, which have a floppy), extended to 640kB, for the Pi (or other Linux),
comprehensive contents section as well! 286sx (a rarity – basically an XT or is there someone adept at
If anyone has started to create a Get an excellent with a 286 processor), 286, 386 translation that could/would
selection of
catalogue of all our contents, though, (720kB floppy, but couldn’t read translate the QL SuperBASIC into
projects and
please let us know! We’d be happy articles the easy the QL disks :( ), a brief fling something that could run on
way with our
to host it on our GitHub repo and with Acorn Electron, 486 (1.44MB the Pi? As I read it, it’s rife with
Official Projects
maintain it diligently. Books! floppy!), Pentium, discovered text boxes spread around the
screen, and of course the screen
RASPBERRY PI DESKTOP
geometry is all sorts of strange.
Dexter N Muir
I understand there is a disc We’ve released a disc with the Unfortunately we don’t have a
which I can put into my PC Raspberry Pi Desktop on direct answer for you, Dexter, and
that contains the Raspberry Pi it a couple of times in the some of the emulators we tried
Desktop for PC? past. However, the easiest to Google don’t all seem to be
I was told that there was a copy way to get it if you can’t find maintained very well. Hopefully
in your magazine which would a copy is to download it and one of our intrepid readers will
provide me with instructions put it on a USB stick – you get in touch and we can sort out
as well as the disc – what’s the can find the downloadable ISO some kind of solution and get
situation on getting a copy if this here: magpi.cc/Tdctna. back to you!
is available? From there you can use Keep an eye out
Digital preservation is an
I’m very keen to get my teeth something like Rufu (rufus.akeo.ie) for when we put important field at the moment,
a disc on the
into this and start learning some to create a bootable USB stick, and cover – it tends
especially with games and
new skills. Hopefully you can then just follow our video on how to coincide with computer systems slowly dying
major updates
help me. to install it: magpi.cc/DEOVGR. It’s to Raspberry Pi
without much fanfare. Maybe this
Paul really that easy! Desktop x86! could be a step towards saving
more old tech?
long subscriber to
05
9 772515 514006
Apr.2018
Issue #05 £6
DREMEL
for HackSpace HACKING
Turn your hand tool
into a table saw
LED
FASHION
magazine
Bring your accessorie
s
to life with LEDs
LADYADA
shouldn’t expire.
We had some
problems with
LIMOR FRIED REVEAL
S ADAFRUIT’S SECRET
S TO MAKING GREAT
HARDWARE
LITHOPHANES CHEE
RLIGHTS PENCILS
the original NEURAL NETWORK
S
discount code
being leaked, though, so if you’re having trouble
sorting out your discount, please drop us a line
and we can try to sort it out.
WRITE TO US
Have you got something you’d like to say?
Get in touch via magpi@raspberrypi.org or on The
MagPi section of the forum at: raspberrypi.org/forums
10
MEARM PI KITS
We’ve teamed up with Mime Industries
to offer ten of these fantastic robot
arm kits for Raspberry Pi.
We reviewed the MeArm Pi in issue #62
and found it “a joy to build and use”. You
can control the MeArm Pi using the twin
joysticks, or with code.
Maker
Says
“The MeArm Pi is
an easy-to-build robot
arm kit that’s designed
to get children (and
adults!) learning
about technology,
engineering, and
programming.”
Mime Industries
CHEERS TO THE
COMMUNITY
Matt Richardson’s take on ensuring community growth for years to come
ust a few weeks ago we celebrated the sixth of a single individual makes a huge difference in the
J birthday of Raspberry Pi. To mark the occasion,
there were ‘Big Birthday Weekend’ Raspberry
quality and sustainability of a recurring event like a Jam.
If you don’t have a Jam near you, you can start one.
Jams all over the world. They took place at Raspberry Pi’s You don’t need permission from us, but if you register
birthplace Cambridge, to my home town Philadelphia, all your Jam, we can put it on the Jam map and make sure
the way to Tokyo, and pretty much everywhere in between. that other Raspberry Pi community members know
Watching these worldwide Jams on Twitter was about it. Don’t be intimidated by the big Jams you may
incredible and a reminder of how large, how widespread, have seen online or in The MagPi. A Jam often starts with
and how enthusiastic the Raspberry Pi community is. The just a few people getting together on a regular basis to
success of the Raspberry Pi over the last six years is due in share the projects they’re making with Raspberry Pi.