Download as pdf or txt
Download as pdf or txt
You are on page 1of 100

BUY IN PRINT WORLDWIDE MAGPI.

CC/STORE

Ałłŏãϰ΋΍΋ NŏēũϰΌΊΌ΍ ę¾÷ĻÿλÙÙ ˆüãϰĢöżÙÿ¾ēϰ|¾łĻØãľľũϰyÿϰę¾÷¾űÿěã

Build dynamic bots with arms and legs

CHAT TO AN
MAKE AN AI-POWERED
ELECTRONIC FORTUNE TELLER
BOP-A-MOLE

DISCOVER GAME
DEVELOPMENT TOOLS

magpi.cc/store

CREATE A RASPBERRY PI WILDLIFE CAMERA


WELCOME

WELCOME
to The MagPi 131

W
e love animals and robots here at The MagPi. There’s
lots of similarity: both need training, feeding, and
nudging with frustration and love.
Lately, we’ve tested some incredible bots with arms, legs,
and limbs. All are controlled by Raspberry Pi and powered by
servo motors. So, we thought it time to limber up and herd
them together into a giant Python Robots feature (page 28).
Lucy

EDITOR
If real-life animals are more your thing, check out Rob’s Hattersley
feature on capturing wildlife with Raspberry Pi (page 66). Lucy is editor of
Setting up camera traps to snap wildlife is a great hobby that The MagPi and was
snapped at quite a
lets you take only photos without scaring critters. few times by dogs
as a pestering child.
This month’s magazine ticks a lot of boxes for me. But magpi.cc
there’s much more to it than animals and robotics. Flick over
the page and take a look at the contents.

Lucy Hattersley Editor GET A


RASPBERRY PI
PICO W
PAGE 22

magpi.cc 03
Full-Code

No-Code / Configure Design

now with a

No-Code WEB UI Designer


Pi 4 and
Analyze W it h R

P RO FES S I O N A L CO N T RO L SYS TE M D E V E LO P M E N T TOO L

Home projects made easy.


CDP Studio, a great software development tool for your home projects. Build
systems for Raspberry Pi, use C++ or NoCode programming, open source libraries,
out of the box support for GPIO, I2C, MQTT, OPC UA and more. Create beautiful user
interfaces. Built for industrial control system development,  .

 
Tel: +47 990 80 900 • info@cdptech.com
CDP Technologies AS // Hundsværgata 8, 6008 Ålesund, Norway
CONTENTS

Contents
> Issue 131 > July 2023

Cover Feature

28 Python Robots 28

Regulars
24 Case Study: Sisyphus
90 Your Letters
97 Next Month
98 The Final Word

Project Showcases
08 Trainbot
12 Ohsillyscope
14 Olga The Fortune Teller
18 Chonky Pocket
20 GPS Pothole Tracker 14

18

Chonky Pocket Olga The Fortune Teller

The MagPi is published monthly by Raspberry Pi Ltd, Maurice Wilkes Building, St. John’s Innovation Park, Cowley Road,
Cambridge, CB4 0DS, United Kingdom. Publishers Service Associates, 2406 Reach Road, Williamsport, PA, 17701, is the mailing
agent for copies distributed in the US and Canada. Application to mail at Periodicals prices is pending at Williamsport, PA.
POSTMASTER: Send address changes to The MagPi, c/o Publishers Service Associates, 2406 Reach Road, Williamsport, PA, 17701.

magpi.cc 05
CONTENTS

Tutorials
40 Game engines for Raspberry Pi 52 62
48 Build a Mole Bop game
52 Taking video on Camera Module
58 Rad your Ride
62 Create interactive stream lights
Taking video on Create interactive
The Big Feature Camera Module stream lights

66
79

Raspberry Pi camera traps


Badger 2040 W
Reviews
72 PuppyPi 84
74 u-maker Box
76 Inky Impression 7.3 inch
77 WuKong 2040
79 Badger 2040 W
80 10 amazing cases
82 Learn Assembly

Community
84 Alistair MacDonald interview
86 This Month in Raspberry Pi Alistair MacDonald interview

WIN ARGON POD SETS


95
1 OF 2
DISCLAIMER: Some of the tools and techniques shown in The MagPi magazine are dangerous unless used with skill, experience, and appropriate personal protection equipment. While
we attempt to guide the reader, ultimately you are responsible for your own safety and understanding the limits of yourself and your equipment. Children should be supervised. Raspberry
Pi Ltd does not accept responsibility for any injuries, damage to equipment, or costs incurred from projects, tutorials or suggestions in The MagPi magazine. Laws and regulations covering
QER]SJXLIXSTMGWMR8LI2EK5MQEKE^MRIEVIHMǺIVIRXFIX[IIRGSYRXVMIWERHEVIEP[E]WWYFNIGXXSGLERKI=SYEVIVIWTSRWMFPIJSVYRHIVWXERHMRKXLIVIUYMVIQIRXWMR]SYVNYVMWHMGXMSR
and ensuring that you comply with them. Some manufacturers place limits on the use of their hardware which some projects or suggestions in The MagPi magazine may go beyond. It is
your responsibility to understand the manufacturer’s limits.

06 magpi.cc
PROJECT SHOWCASE

Trainbot/OnlyTrains
A grandstand view led a Swiss hobbyist to record passing trains using
Raspberry Pi’s camera, learns Rosie Hattersley

L
iving in sight of a railway has proved 8ZOPW ,=L^[MP]]d;T_ZRZZO`^PNZY_]ZWWTYR
inspirational for many: Suggs from Madness; the door to a co-working space at the ETH
Rod Stewart, your writer’s Dad! It was also the Entrepreneur Club where he was a member, using
catalyst for Trainbot, an automated photography Slack (magpi.cc/dooropener). There isn’t much
project triggered by the engines and carriages call for the computer vision skills that were part
running past the window of maker Jonathan Müller of his degree course, but Jonathan enjoys creating
in Zurich, which stitches shots together to appear projects that exploit his technical knowledge.
as complete trains. Acknowledging the geeky but When Jonathan moved into his apartment two
Jonathan
MAKER

passionate hobby of trainspotting, he created a years ago, he quickly realised that the unique
Müller website on which to view the resulting photos and view it gave him of the trains going by would
named it OnlyTrains. make for an ideal project subject. “Inspired by the
Software engineer
Jonathan enjoys ^WT_^NLYʭYT^SP][SZ_ZR]L[S^Q]ZXMTVP]LNP^4
challenging code Room with a view then came up with the idea of creating pictures
projects and 5ZYL_SLYʭ]^_NLXPLN]Z^^=L^[MP]]d;T with similar aesthetics – but of trains instead of
has been using
Raspberry Pi for
when he was still an electrical engineering bikes, and a cheap camera instead of specialist
nearly a decade. ^_`OPY_MLNVTY3P[]ZX[_Wd[`_ST^ʭ]^_ hardware,” he explains. Slit-scan photography
trains.jo-m.ch

Each image is made


up of small patches,
each of which has
been processed
individually in order
XSGVIEXIEWMRKPIǻREP
composite image

08 magpi.cc Trainbot/OnlyTrains
PROJECT SHOWCASE

Trainbot recognises when a train


is passing by and automatically
triggers the camera shutter and Photos captured by
turns them into a GIF reminiscent Raspberry Pi HQ Camera 3
of a slit-scan animation are uploaded to a web server
via FTP where they can be
viewed and ‘favourited’ by
OnlyTrains fans

The machine-learning
algorithm is largely successful
at distinguishing white-painted
carriages from snow, most
weather conditions, and neatly
stitches the resulting photos

Quick FACTS
> Jonathan’s day
job involves work
with drones

> Trainbot originally

He was keen to use the Go support.” It is also powerful enough to handle the
graphical computations required, while being less
used a webcam
housed in a kids’ toy

programming language’s expensive than a board with a dedicated graphics


> Better photos
processor. He notes that “the computer vision
computer vision and cross- used in Trainbot is fairly naïve and simple. There
and a smartphone
ETTcFVSEHIRIH
is no camera calibration, image stabilisation,
compilation tools, and undistortion, perspective mapping, or ‘real’
its appeal

see how well it worked object tracking.” > OnlyTrains fans can
now save special

alongside older tech Name that train! shots as favourites


BT_S[WPY_dZQ=L^[MP]]d;TLYO7TY`cPc[P]TPYNP
> You can see
under his belt, Jonathan’s challenges for the
Jonathan’s own
creates an animation from a series of still shots. Trainbot included creating mounting plates and
favourites at
For his train version, Jonathan was keen to use Z_SP]^XLWW[L]_^_Zʭ_TY^TOP_SPbL_P][]ZZQ tinyurl.com/
the Go programming language’s computer vision case he bought, so the AI camera setup could live onlyfaves
and cross-compilation tools, and see how well outdoors on his balcony, as well as developing
it worked alongside older tech such as SQLite and testing the computer vision algorithm. He
LYO1?; needed data with which to train the algorithm
5ZYL_SLYNSZ^P=L^[MP]]d;T_Z]`Y?]LTYMZ_ and spent “quite some time” recording video with
L^ɭT_ZʬP]^LWW_SL_T^YPPOPOQZ]^`NSL ST^[SZYPʭ]^_MPQZ]Pɭ^PXTXLY`LWWdNSZ[[TYR
project: quite a lot of compute power, cheap, up the recordings and setting a test harness with
good ergonomics and docs, and good software them (magpi.cc/autoset0testgo)”.

Trainbot/OnlyTrains magpi.cc 09
PROJECT SHOWCASE

There was also a lot of “testing and tuning” notes that this led to missed frames, or wrongly
involved in ensuring the computer vision setup estimated ones, which led to chopped-up images.
bL^LMWP_Z]PNZRYT^PXZ^__]LTY^ɭ4^ZZYʭR`]PO To address this, he added a step after the initial
out that patch-matching alone is not robust image gathering which applied an estimation and
enough to estimate train velocity.” Jonathan ^XZZ_STYR[]ZNP^^`^TYR=,9>,.LYOɭL^TX[WP
s = v0 + a*t model” to estimate start velocity and
LNNPWP]L_TZY=,9>,.T^LNWL^^TNLWNZX[`_P]aT^TZY
approach used to estimate a model when there
are lots of outliers. He wrote much of the code
himself, including instructions for patch-matching
and the low-level computer vision, to keep things
The mock-up model
was housed in a toy
as light as possible.
casing and had a With half of the coding and cross-compilation
webcam for a camera
done in Go, Jonathan tried out Trainbot on his
Another of Jonathan’s =L^[MP]]d;T,_ʭ]^__SP[]ZUPN_`^POLbPMNLX
Raspberry Pi projects
provides timetable M`_L^^ZZYL^5ZYL_SLY]PLWT^PO=L^[MP]]d;T
information –
also makes camera modules, he switched over to
something he’s keen to
integrate into Trainbot HQ Camera Module 3, resulting in “much higher

10 magpi.cc Trainbot/OnlyTrains
PROJECT SHOWCASE

Set up a slit-scan

ŽŸå±ƋųĜŞŅÚØŅųŅƋĘåųĀƻĜĹčĵåÏʱĹĜŸĵØ
01 ƋŅƋų±ĜĹƼŅƚųϱĵåų±ŅűŸĜĹčĬåŸŞŅƋţ¥Ņƚ
ƵĜĬĬĹååÚŞĬåĹƋƼŅüüŅŅƋ±č埱ĵŞĬåŸŅüƵʱƋåƴåų
ƼŅƚűųåŞĘŅƋŅčų±ŞĘĜĹčƋŅƋų±ĜĹƋĘåŸŅüƋƵ±ųåƋŅ±ƚƋŅě
ųåÏŅčĹĜŸåƋĘåĜųŞųåŸåĹÏåţ

ŽŸåIŅűƋʱĹűŸ:ŅÏŅÚåƋŅƋų±ĜĹƋĘåŸƼŸƋåĵ
02 ±ĹÚŸƋĜƋÏĘƋŅčåƋĘåųƋĘåĜĵ±čåŸĜƋųåÏŅčĹĜŸåŸ
±ŸÆåĬŅĹčĜĹčƋŅƋĘ埱ĵåƴåĘĜÏĬåŅųŅÆģåÏƋ×
magpi.cc/trainbotţ
Raspberry Pi is protected
inside a waterproof case

I soon figured out that patch-matching


alone is not robust enough to estimate
train velocity

image quality (and very good software support via


libcamera) than a cheap webcam, at a low price
[ZTY_ɮ9Pc_SPTY_PYO^_ZOPaPWZ[_SPXLNSTYP
learning element to recognise and highlight
‘atypical’ trains, something that will be aided by
Switching to Raspberry
him also adding details from the GTFS+/GTFS Pi HQ Camera Module 3
resulted in far superior
real-time timetables available in machine readable
photos, which Trainbot
format from Swiss public transport companies. cleverly patches together

„åƋƚŞƋĘåϱĵåų±Ø±ŸŞÆåųųƼ{ĜĉرĹÚ
03 ÏŅĹĹåÏƋŅųŸĜűŸƋƚųÚƼƵå±ƋĘåųŞųŅŅüϱŸå
ƵĘåųåŞĘŅƋŅŸϱĹÆåƋ±ĩåĹƵĜƋĘŅƚƋƋĘåĬåĹŸčåƋƋĜĹč
ƵåƋţŽŸå8‰{±ĹÚ„}XĜƋåƋŅ±ƚƋŅĵ±ƋĜϱĬĬƼƚŞĬŅ±Ú
ŞĘŅƋŅŸƋŅ±ƵåÆŸåųƴåųüŅųåƴåųƼŅĹåƋŅƴĜåƵţ

Trainbot/OnlyTrains magpi.cc 11
PROJECT SHOWCASE

Ohsillyscope
With Thomas McDonald’s ingenious riff on the oscilloscope,
live music performances don’t just sound great, they look
good too, as David Crookes discovers

W
L_NS_SPZʯNTLWaTOPZQZ]_SP,]N_TN ?SP]P^`W_T^L[]ZUPN__SL_NLYMP_LVPYZY_SP
8ZYVPd^ɪ2]LXXdYZXTYL_PO^TYRWP ]ZLOL^LaT^`LWLNNZX[LYTXPY__ZX`^TNLW
Do I Wanna Know?Q]ZXLYOdZ`ɪWW [P]QZ]XLYNP^ɭ,_ʭ]^_4bL^_STYVTYR_SL_4NZ`WO
^PP^Z`YObLaP^aTM]L_TYRTY^dYNS]ZYT^L_TZY SLaPT_bZ]V_S]Z`RS84/4FL[]Z_ZNZWbSTNSWP_^
bT_S_SP[P]N`^^TZYWPLOR`T_L]LYO^TYRP],WPc X`^TNLWTY^_]`XPY_^NZX[`_P]^LYOZ_SP]
?`]YP]MPQZ]P_`]YTYRTY_ZLYLYTXL_TZY SL]ObL]PNZXX`YTNL_PbT_SPLNSZ_SP]HM`__SP
4_ɪ^L^TX[WPdP_NZX[PWWTYRPʬPN_LYOT_NP]_LTYWd TOPLZQYPPOTYR_ZMPSZZVPO`[_Z_SP^ZQ_bL]P
^_]`NVLNSZ]ObT_SX`^TNQLY^^`][L^^TYRXZ]P ,MWP_ZY7TaPVTWWPO_SPXZ_TaL_TZY_Zb]T_PLYPY_T]P
Thomas
MAKER

_SLYLMTWWTZYaTPb^ZYDZ`?`MPTYɭ8d WTM]L]d_ZOZ^Z4bLY_PO^ZXP_STYR_SL_OTOYɪ_
McDonald QLaZ`]T_P[L]_ZQRZTYR_ZNZYNP]_^T^LWbLd^RZTYR ]P\`T]PMPTYRMdLNZX[`_P]_Z]P[]P^PY_X`^TNɮ
_ZMP_SPaT^`LW^LYO_SPX`^TNaTOPZOPʭYT_PWd
Thomas graduated
from UCCS with a TY^[T]POXPɮ^Ld^?SZXL^8N/ZYLWO4_ɪ^WPO_Z Looking good
major in Computer _SPN]PL_TZYZQLYZ[PY^Z`]NPaP]^TZYZQLY ?SZXL^WZaP^`^TYRST^N]PL_TZYɭ4_ɪ^^XLWWLYO
Science and a Z^NTWWZ^NZ[PbSTNSOT^[WLd^WTaPL`OTZL^L [Z]_LMWPɧ^ZXP_STYRdZ`U`^_[W`RTYVYZbTYR_SL_
minor in Statistics.
He’s an outdoors
bLaPQZ]X?SZXL^NLWW^T__SPɭ:S^TWWd^NZ[Pɮ
enthusiast, dog dad, ?SP[]ZUPN_LWWZb^?SZXL^_Z[WLdX`^TNLW
and music junkie. TY^_]`XPY_^LYO^PP_SP_`YP^aT^`LWT^POL^bLaP^
magpi.cc/ ZYL!Ÿ!70/XL_]TcOT^[WLdɭ,Q_P]RP__TYR_SP
ohsillyscope 70/XL_]TcLYO[WLdTYRL]Z`YObT_ST_4ʭR`]PO
_SP]PbZ`WOSLaP_ZMPLbLd_SL_4NZ`WO`^PT_
bT_SXdR`T_L]LYOZ_SP]X`^TNLWTY^_]`XPY_^ɮ
SPPc[WLTY^ɭ4_ɪ^LWbLd^]PLWWdQ`YbL_NSTYR
_SPWTaP^TRYLWQ]ZX^dY_SP^T^P]^ZQ_bL]PM`_4
TXLRTYPO4NZ`WOXLVP^ZXP_STYRXZ]P[Sd^TNLW
bT_S _SPXL_]Tcɮ

Live jives
?SPTOPLSPPc[WLTY^MZTWPOOZbY_Z]PRT^_P]TYRL
WTaPL`OTZ^TRYLWbT_SL=L^[MP]]d;TNZX[`_P]
ɭ/ZbY_SPWTYP4bLY__ZXLVP^ZXPXZ]P
NZX[WTNL_POaT^`LW^_SL_L]P]PLN_TaP_Z_SPL`OTZ
^TRYLWNZXTYRTYɮSP^Ld^
4_SL^TYaZWaPONZYYPN_TYR_SPXL_]Tc[LYPW_ZLY
,OLQ]`T_=2-8L_]Tc3,?LOOZYɭ4SLaP
=L^[MP]]d;T]PNZRYT^P_SPL`OTZTY_P]QLNPT_ɪ^
SZZVPO`[_ZLYO4ɪaP`^PO7TY`cɪ^,OaLYNPO7TY`c
>Z`YO,]NST_PN_`]P,7>,WTM]L]d_Z]PLO_SP^TRYLW
Q]ZX_SPTY_P]QLNPLYO[WLNPT_TY_Z_SP.NZOP
]`YYTYR_SP70/XL_]Tcɪ^WTM]L]dɮ?SZXL^^Ld^
Thomas wanted a
way to play his guitar ɭ4_ɪ^^LX[WTYRL__SP]PQ]P^S]L_PZQ_SP^N]PPY
and see a visual
bSTNSXLVP^L]PLWWdNZZWaT^`LWɮ7PL]YXZ]P
representation of the Once the music starts, the project – which can use
tunes on screen at LW^L[]ZUPN_Z]R a Raspberry Pi Zero computer – will burst into life

12 magpi.cc Ohsillyscope
PROJECT SHOWCASE

The Adafruit RGB Matrix


HAT means setting
up the Ohsillyscope is
rather straightforward

The Ohsillyscope
reads live audio
The 64×64 LED matrix from ALSA sources
displays a waveform image
in real-time and it can do
so in various colours

Quick FACTS
> The device visually
represents music

> It displays it on an
LED matrix

> ALSA is used to


interpret an
audio signal

> Ohsillyscope cost


$145 to make

> Thomas wants


PaP]d_STYRT^^P_`[ɮSP^Ld^ɭ?SP70/XL_]Tc others to collaborate
3,?bL^XLOPQZ]=L^[MP]]d;T^ZT_bL^L
YZM]LTYP]4_LW^ZSPW[PO_SL_4SLOLNZ`[WPZQ
=L^[MP]]d;TEP]ZNZX[`_P]^WLdTYRL]Z`YOMPRRTYR
_ZMP`^POɮ
.`]]PY_WdSPɪ^SZZVPO_SP:S^TWWd^NZ[P_Z_SP;,
^d^_PXTYST^MLYO[]LN_TNP]ZZXɭ4_[TNV^`[_SP
ML^^R`T_L]^LYOO]`X^XLVTYRLYTY_P]LN_TaP

It’s sampling at the refresh


rate of the screen

^SZbQZ]LYdZYPbL_NSTYRɮSP^Ld^ɭ?SP[PZ[WP
bPɪaP^SZbY_SP:S^TWWd^NZ[P_Z^ZQL]^PPX_ZWZaP
You can create
T_LYOZYNPbP^_L]_RTRRTYRXZ]PT_ɪ^^`]P_ZRP_ your own version
of the Ohsillyscope
_SPMLYOXZ]PL__PY_TZYɮBPɪ]POPʭYT_PWd^`]P
since the code is
_SL_T_ɪ^RZTYR_ZWZZVRZZOZY_SPOLYNPʮZZ] open-source

Ohsillyscope magpi.cc 13
PROJECT SHOWCASE

Olga The
Fortune Teller
Admiring glances across an office led to a creative
partnership involving several Raspberry Pi models
and some charming AI, learns Rosie Hattersley

L
ast issue, we brought you details of the Love
Machine ChatGPT project which dished out
compliments and sometimes sweets based
on cutesy WhatsApp exchanges. Raspberry Pi
^_LʬP]^LYOThe MagPiXLRLeTYP]PLOP]^bP]PYɪ_
_SPZYWdZYP^_ZQLWWQZ]T_^,4NSL]X^,NZX[LYd
_SL_^SL]P^ZʯNP^[LNPbT_S7ZaP8LNSTYPXLVP]^
6LVL[Z7LM^bP]PP\`LWWdPY_]LYNPOLYO^ZZY
XLOPLXZaP[]Z[Z^TYRLNZ`[WTYR`[LYOL
RWZb`[ ?SP]P^`W_%:WRL?SP1Z]_`YP?PWWP]L
^STYdYPb.SL_2;?XZOPWOP^TRYPO_ZL[[PLW_Z
_SP4Y^_L^LaadTYʮ`PYNP]VPPY_ZNSPNVZ`_MZ_S
_SPWL_P^_^VTYNL]PZ[_TZY^LYO]PNPTaP]PL^^`]TYR
XP^^LRP^LMZ`__SPT]Q`_`]PQLXPLYO
QZWWZbP]NZ`Y_

Altered images
:WRL?SP1Z]_`YP?PWWP]bL^OP^TRYPOTY
[L]_YP]^ST[bT_S,W_P]/LNZX[LYd_SL_OP^TRY^
OT^[WLd^QZ]]P_LTWP]^-Z_SNZX[LYTP^L]PML^POL_
3ZYPhone.londonLN]PL_TaP^[LNPTY0L^_
7ZYOZY?SP_PLXQ]ZX,W_P]/bL^ZY_SPWZZVZ`_
ɭQZ]^ZXP_STYRaT^`LWWdL__PY_TZYR]LMMTYRɮ^Lb
Kakapo Labs:
MAKER

6LVL[Zɪ^7ZaP8LNSTYPRZ__LWVTYR_ZT_^XLVP]^
India, Will LYO_STYR^bPY_Q]ZX_SP]P
Lahr; AlterD:
BT_SL]P_LTWOT^[WLd_]LOP^SZbNZXTYR`[
Will Lucking,
Claire Richards TXXTYPY_Wd,W_P]/NSZ^PLNL]OMZL]OML^PO
OP^TRY_Z^SZbZʬ_SPXL_P]TLWɪ^[Z^^TMTWT_TP^ɭ4_
AlterD creates bL^TX[Z]_LY__SL_T_OTOYɪ_WZZV_ZZ^[PNTʭNLWWd
retail displays for
WTVPLYd[L]_TN`WL]M]LYO^Z_SPdbPY_QZ]LQ`Y
clients and shares
SǽGIWTEGI[MXL \`T]VdO]PLXWTVPWZZV?SPdbLY_PO_ZLOOLY
interactive design TY_P]LN_TaPPWPXPY__ZPYNZ`]LRP[PZ[WP_ZTY_P]LN_
agency Kakapo
bT_S_SP^_LYOLYO^_L]_NZYaP]^L_TZY^ɮ6LVL[Z
1EFW[LMGLVSYXMRIP]
YWIW7EWTFIVV]5MMR 7LM^QZ`YOP]BTWW7LS]Pc[WLTY^
its creations. ,^bT_S7ZaP8LNSTYPXZMTWPNZYYPN_TaT_dbL^
magpi.cc/ aT_LW^Z_SPdNSZ^PL;TNZB%ɭ^TX[WPWZbNZ^_
kakapolabs LYO^XLWWM`_L__SP^LXP_TXPFT_HNLY]`YLQ`WW

14 magpi.cc Olga The Fortune Teller


PROJECT SHOWCASE

Olga’s beauty secrets involve lashings


of perspex, cushioning cardboard, and
colour-changing mood lighting, plus
some Pico W-controlled eyebrow raising

Once you’ve checked your


visage in the helpfully
supplied make-up mirror,
scan the QR code below
it to engage Olga in a
WhatsApp chat

Quick FACTS
Olga gets ChatGPT to
foretell your fortune, > 4PKEGSWXEVSYRH
sending it to a cloud fXSFYMPH
server for Pico W to
download and deliver > .X[EWSVMKMREPP]
as printed ticket KSMRKXSFIEZMWYEP
KYIWWMRKKEQI

> Instead, she


FIGEQIEƵHMVIGXSV
of divination’

> LIJIEXYVIW
(LEX,58ƶWRI[GLEX
(SQTPIXMSRQSHIP

> It can tell the


JSVXYRIWSJQYPXMTPI
;LEXW&TTYWIVW

Olga The Fortune Teller magpi.cc 15


PROJECT SHOWCASE

.SL_2;?QZ]LMWLNVLYObST_PNL]_ZZYTXLRPZQL
QZ]_`YP_PWWP]1Z]_`YP_Pc_LYOR]L[STNL]P
TX[Z]_POLYOPYNZOPOL^LYTXLRP_SL_NLYMP
]PNZRYT^POMdE;7_SPWLYR`LRP`^POMd_SP
[]TY_P]7LRRd[P]QZ]XLYNP[]ZNP^^TYRLYO
Z`_[`__TYR_SPTXLRP^WPO_SP6LVL[ZLYO,W_P]/
_PLX_Z^bT_NSQ]ZX_SP`Y]PWTLMWPPcT^_TYR
BPM>ZNVP_OPWTaP]d^P_`[?SPɭX`NSMP__P]ɮ
^d^_PX_SPdTX[WPXPY_PO^LaP^_SP_TNVP_TXLRP
ZYWTYPLYOU`^_`^P^BPM>ZNVP__Z^PYO;TNZB_SP
@=7TYZ]OP]_ZOZbYWZLOLYO[]TY_T_

Fortune favours
:WRLSP]^PWQT^ZQNZ`]^PLWL]RP[L]_ZQ_SP
L[[PLW>SPSL^LQLNPN`_Q]ZXL^SPP_ZQ[P]^[Pc
4PKEƶWKSVKISYW bT]PWP^^^_LNVbSTNST^PL^d_Z`^PɮBT_S LYO^ZXPPc_]PXPWdPc[]P^^TaPPdPM]Zb^_SLYV^_Z
face and expressive
I]IFVS[W 8TN]Z;d_SZYZY_SP;TNZB_STYR^bZ]V[LTYWP^^Wd L;TNZBXTN]Z^P]aZ^LYO^ZXPMWLNV_S]PLO_SL_
[IVIPEWIVGYX LYO_SPOPaPWZ[XPY__TXPT^^SZ]_4_ɪ^`^POSP]P SPW[_SPXbTRRWP>SPLW^ZTX[L]_^SP]bT^OZXaTL
_ZNZXX`YTNL_PbT_SLEPM]L_SP]XLW[]TY_P]aTL LQLYNdYPbXPLY^ZQNZXX`YTNL_TYRO`P_Z
LY=>NZYYPN_TZYLYO[]ZX[_T__Z[]TY_Z`_L NSLYRP^_Z.SL_2;?_SL_:[PY,4]PNPY_Wd
^_LYOaT^T_Z]ɪ^QZ]_`YP_TNVP_.SL_2;?T^ TX[WPXPY_POM`_T_ɪ^^_TWWML^POZYBSL_^,[[
TY^_]`N_PO_Z%ɩ;]P_PYOdZ`L]PLQZ]_`YP_PWWP]LYO LYO?bTWTZWTVP:WRLɪ^^TMWTYR_SP7ZaP8LNSTYP
_PWW_SP[P]^ZYdZ`L]P_LWVTYR_ZɧbSZT^NLWWPO ^PPThe MagPi magpi.cc/130
9,80ɧ_SPT]QZ]_`YPTYL[ZPXZQ_S]PPZ]QZ`] ?SPM]TPQQ]ZX,W_P]/bL^QZ]L[WLdQ`W
^SZ]_WTYP^8LVP^`]P_SPT]QZ]_`YPT^aLR`PM`_ TY_P]LN_TaPOT^[WLd^SZbTYRZʬ_SP[Z^^TMTWT_TP^QZ]
[Z^T_TaP 4YNW`OPLW`NVdT_PX]P_LTW]PWL_POɪ ]P_LTW^P__TYR^3ZbPaP]BTWW[ZTY_^Z`__SL_
,NZYN`]]PY_]P\`P^_T^XLOP_Z/,770LY N]PL_TYR^ZXP_STYRaP]d\`TNVWdLYOPʯNTPY_Wd
TXLRPRPYP]L_Z]XLOPMd_SP^LXP[PZ[WPL^ `^TYR^PaP]LW;TNZB^bSTNSMPTYRNZYYPN_PO

(SPSYVGLERKMRK
1*)WQEOIXLI
booth design
QSVII]IGEXGLMRK
and hide Olga’s
GEVHFSEVHSYXPMRI

16 magpi.cc Olga The Fortune Teller


PROJECT SHOWCASE

Characterful interaction

Olga’s look is very much down to you. Create


01 the fortune teller’s face with or without
a computer using items such as cardboard and
Olga herself is, of course, a large part Perspex, adding micro servos and Pico W if you’d
like to include changing facial expressions.
of the appeal. She has a face cut from
a sheet of perspex and some extremely
expressive eyebrows
bT]PWP^^WdLaZTO^_SPYPPOQZ]WZYRNLMWP]`Y^ Olga can hypnotise
IZIRXLIQSWXGEWYEP
XLVTYR`^PZQ^TX[WPbPM^P]aTNP^SL^LWW^Z]_^ZQ TEWWIVF]MRXSLEZMRK
[Z_PY_TLWɭBPɪaPMPPYPc[WZ]TYRXZ]P[Z^^TMTWT_TP^ XLIMVJSVXYRIXSPHƾ

QZ]TY_P]LN_TZY_S]Z`RSL^SZ[bTYOZbɧ`^TYRL
[SZYPL^LOPaTNP_ZWP_^ZXPZYPZ`_^TOP_SP
bTYOZb[WLdbT_S^ZXP_STYRTY^TOP_SPbTYOZbɮ
SP^Ld^LYOT^`[QZ]NZWWLMZ]L_TYRbT_SZ_SP]
[L]_YP]^QZ]XZ]PQ`Y[WLdQ`W[]ZUPN_^
ɭ:WRLXLdYZ_MPLMWP_Z[]POTN__SPWZ__P]dZ]
Pico W controls the LED lights around Olga’s
_PWW`^bSPY_SPNZ^_ZQWTaTYRN]T^T^bTWWPYOM`_ 02 make-up mirror, as well as the servo motors
bSL_^SPNLYOZT^ZʬP]LRWTX[^PTY_Z_SPQ`_`]P creating her facial expressions, while another
ZQTY_P]LN_TaP]P_LTWPc[P]TPYNP^ɮ connects to the Zebra printer to produce the all-
important fortune readings.

Use the instruction in the main article to get


03 ChatGPT to tell a fortune. Connect everything
to a web server and thermal printer to print them out
After a brief WhatsApp on demand.
chat, the booth prints
SYXETVSRSYRGIQIRX

Olga The Fortune Teller magpi.cc 17


PROJECT SHOWCASE

Chonky Pocket
Dan Norris’s project looks like a video game handheld console, but it’s a
computer that can be operated with one hand. David Crookes takes a look

O
n-screen keyboards work well, but a to incorporate a keyboard, scroll wheel, and
physical set of keys remains preferable, touchscreen, and include a laptop-style battery
certainly if you’re going to be entering a that would report its state of charge to the OS.
lot of text. With this in mind, Dan Norris began to
work on his Chonky Pocket computer. He believed Key points
that, in order to create a device comfortable to At the Chonky Pocket’s heart is a Raspberry
use, jamming in a full-size Qwerty keyboard Pi 4 computer. “I usually use Ubuntu and it’s
wasn’t going to work. R]PL__SL_=L^[MP]]d;TT^ZʯNTLWWd^`[[Z]_POɮ
Dan
MAKER

Instead, he has limited his pocket-sized Dan says. It’s hooked up to a 5-inch HDMI
Norris computer to just ten keys and, as well as being touchscreen with a speaker and, of course, a
Dan is a DevOps able to type straightforward documents with handful of keys. They’re ‘chorded’ which means:
and infrastructure T_T_ɪ^RPL]PO`[^[PNTʭNLWWd_ZLWWZb`^P]^_Z several keys need to be pressed together to enter
engineer in code in Python. What’s more, it’s wrapped in characters, words, phrases, or commands.
Northern California
a beautiful enclosure that makes the Chonky “The keyboard layout is mostly just the eight-
who enjoys hiking
ERHFYMPHMRKWXYǺ resemble a Nintendo Game Boy handheld. It really key ARTSEYIO (artsey.io) chording layout with
is an object to desire. two extra keys mapped to ‘)’ and ‘(‘ and chorded
magpi.cc/
chonkypocket “I wanted a pocket-sized Linux computer ‘:’ – keys that normally require a layer shift
with a physical keyboard and I sort of hacked with the ARTSEYIO layout.” This enables Python
something together last year that wasn’t very coding. “It was a bonus that the extra keys made
nice,” Dan explains. “I decided to have another the keyboard physically symmetrical, so I could
go at it this spring when I got a pre-release change the layout for either hand,” Dan adds.
Amp Ripper 4000 PSU to try out.” His goal was Of course, it’s going to take some getting
used to. “I can type about 20 words per minute
(wpm) with it when I practise a bit, but there
are folks on the ARTSEYIO Discord who can do
more than 40 wpm,” Dan continues. “If I wanted
to type faster with one hand, I’d be inclined
to use half of a Corne split keyboard (CRKBD)
which has more thumb buttons for layer shifting
and more direct access to symbols, numbers,
and CTRL/SHIFT/ALT.”

Powering on
The build posed some challenges. “Modifying the
battery kernel module for this was interesting,”
Dan says. “I haven’t touched any C code since
college and the window manager would crash
when I loaded the module in Raspberry Pi OS.
I’m just lucky that it worked in Ubuntu without
having to do much troubleshooting.”
Power was hard to get right too. “Even using
the wrong connector between a battery and the
This is an early draft build of the project
with a vertical screen and a GPIO keyboard boost/charge board can cause voltage warnings

18 magpi.cc Chonky Pocket


PROJECT SHOWCASE

The Game Boy-style case needs


a minimum thickness of 32 mm to
ǻXXLIHMWTPE]ERH7EWTFIVV]5M

Quick FACTS
> This is Dan’s
tenth cyberdeck-
VIPEXIHcTVSNIGX

> It uses a chording


keyboard

Dan says a lot of apps


> The Game Boy-
work nicely with a mouse
style case helped
The mechanical keyboard scroll wheel ,even if you
simplify the design
YWIWPS[TVSǻPI(LSG don’t have a mouse
switches with keycaps. The > &PPXLI81ǻPIW
keyboard uses chording are on Dan’s
and has mouse emulation GitHub page

> There’s a gyro and


accelerometer
inside too

and rebooting with Raspberry Pi 4,” he explains. The batteries will


,YOSPSL^]Pb]T__PY_SP2;4:VPdMZL]Oʭ]XbL]P last for up to a day:
“They’re heavy
a couple of times. “It was an opportunity to learn and bulky,” Dan
about the current state of GPIO programming on says. “But it’s cool
not having to drag
=L^[MP]]d;TbT_SɩWR[TZɪLYOʭR`]PZ`_SZb_Z around a charger”
use ‘uinput’.”

I usually use Ubuntu and


it’s great that Raspberry Pi
is officially supported
Dan hopes many people will enjoy building
their own version and already plans for a build
that includes a second HDMI port, external pins, a
OT^[WLd_SL__`]Y^ZʬbSPYTOWPLYOXZ]Pɭ4ɪaP
gotten lots of supportive comments on Reddit
The Raspberry Pi computer ports can be accessed from
for this build and some nice media coverage. It’s
the back. There’s also a kickstand, power switch, and
accessory mount been a lot of fun,” he says.

Chonky Pocket magpi.cc 19


PROJECT SHOWCASE

GPS Pothole Tracker


If problematic potholes drive you round the bend, this practical device might
improve their chances of being repaired. Nicola King checks her tyres

P
otholes are becoming an increasing problem For portable power, the GPS Pothole Tracker uses
the world over – on regular trips, you get L@>-[ZbP]MLYV:`_TY_SPʭPWObSPY_SP`^P]T^
to know the spots on the road to avoid near a pothole, they press the button. If the GPS is
LYObSPYdZ`ʭYOLYPbSLeL]OZ`^SZWPZY locked, the tracker records the button press in the
your highway, you and your suspension certainly FRAM. “The Pico W takes in the input from the
QPPW_SP^ZXP_TXP^OLXLRTYRPʬPN_^So, what GPS, gaming button, and then stores the GPS
if you had a way of recording the exact positions locations, and gives output to the user in the form
ScienceDude1990 ZQ_SP^P_]Z`MWP^ZXPʭ^^`]P^LYOQ]LN_`]P^^Z of the light of the button, and the buzzer,” explains
MAKER

that you could then alert the relevant authorities ScienceDude1990. When the user gets home, they
ScienceDude1990 is _Z ʭc_SPX* NLY_SPYZ[PYL_Pc_ʭWPLYO^PYOLYd[P]_TYPY_
a maker in Canada, pothole information onto whoever needs to have it.
and an electrical
engineer by
Finger on the button ScienceDude1990 says that Raspberry Pi Pico W
training. He enjoys Well, it’s a nuisance that ScienceDude1990 decided was easy to use with MicroPython and Thonny
QEOMRKSǺFIEX to tackle, following one particularly hard and when coding for this device. “The development
projects, and writing pothole-inducing winter in his native Canada. He environment is very lean, fast to learn, and perfect
[IPPGSQQIRXIH
was determined to try and deal with the headache for these kinds of projects.” The most challenging
and clear code.
of his local potholes for the greater good: “I think it
magpi.cc/
potholetracker is my civic duty to help out. Potholes can be
annoying for cars, and very dangerous for cyclists.” Potholes can be annoying
After gathering a few components, a little
breadboarding, coding, and soldering ensued, and for cars, and very
the result of his endeavours is the GPS Pothole
Tracker, the key elements of which are a Raspberry
dangerous for cyclists
To make the project
parts stable but Pi Pico W, an Adafruit LED arcade button, a buzzer,
reusable, he soldered
a u-blox antenna module (for GPS), and a FRAM aspect was learning how to use the ‘os’ commands
rows of headers to
plug the boards into (ferroelectric RAM) breakout for data storage. in MicroPython to work with the FRAM board.
He describes using the FRAM as a “side quest”,
as he was keen to see how he could work with the
FRAM chip and the Pico W, and says he was
“pleasantly surprised” at how easy it was to format,
mount, and use.

Mission accomplished
The good news is that ScienceDude1990 has actually
used his device on his local roads, alerted his
obliging local authorities to the presence of pesky
potholes, and got the job done! “I used it to log the
potholes in the spring, and then submitted them to
my city’s service request system. The potholes were
ʭcPOTYL_TXPWdXLYYP]5Zd ɮ
All that’s needed now is a case of some kind to
protect the various components and make it a little
more aesthetically pleasing, as currently the device
T^aP]dX`NSTYT_^]LbQZ]Xɭ/PʭYT_PWdRZTYR_Z

20 magpi.cc GPS Pothole Tracker


PROJECT SHOWCASE

A FRAM module is Warning!


used to store the Drive safely
GPS co-ordinates
of potholes If you make this project,
IRWYVIWEJIX]GSQIWǻVWX
behind the wheel. As
ScienceDude1990 notes:
A custom PCB was “Always remember to
made for the u-blox GPS respect your distracted
driving laws, so maybe
module, but you could KIXEGSTMPSXXSLIPT$ƹ
YWIEHMǺIVIRXSRI
magpi.cc/drivesafely

The user presses a large


arcade button with LED
when a pothole is spotted

Quick FACTS
> The total cost of
the make was just
under Can$95

> The largest line


item was the GPS
module – the part
cost around $50
The wiring is all on the rear of the prototyping board, including
connections to the button and buzzer
> ScienceDude1990
spent around two
make a nice case for it,” he says. “[I’ll] probably weeks’ worth of
laser-cut something out of clear acrylic at the free time on
library makerspace.” the project
It’s a relatively simple make, but
ScienceDude1990 suggests a little bit of soldering > His project code
practice might be useful before a complete newbie is available on
GitHub: magpi.cc/
attempts to make one. “I would suggest
potholetrackergh
M]PLOMZL]OTYRbT_S[`^STYbT]P^ʭ]^_?SPY
practise soldering, or use some kind of quick- > He now plans
connector scheme. His informative Hackaday to make an
project page (XLR[TNN[Z_SZWP_]LNVP]) gives links oscilloscope
to the GitHub code he wrote, and includes a Pico with Pico’s PIO
;LIRTVIWWIHXLIEVGEHIFYXXSRƶW1*)ǼEWLIWERHXLI
pinout connection diagram. FY^^IVWSYRHWXSGSRǻVQXLITSXLSPILEWFIIRVIKMWXIVIH functionality

GPS Pothole Tracker magpi.cc 21


SUBSCRIPTION

SUBSCRIBE TODAY
FOR JUST £10
Get 3 issues + FREE Pico W
Subscriber Benefits
FREE Delivery
Get it fast and for FREE

Exclusive Offers
Great gifts, offers, and discounts

Great Savings
Save up to 23% compared to stores

Subscribe for £10


Free Pico W
3 issues of The MagPi
Free delivery to your door
£10 (UK only)

+
Subscribe for 6 Months
Free Pico W
6 issues of The MagPi
Free delivery to your door
£30 (UK) $43 (USA)
€43 (EU) £45 (Rest of World)

Subscribe by phone: 01293 312193


Subscribe online: magpi.cc/subscribe
Email: magpi@subscriptionhelpline.co.uk
Subscribe for £10 is a UK-only offer. The subscription will renew at £15 every three months unless
cancelled. A free Pico W is included with a 6-month subscription in USA, Europe and Rest of World.

22 magpi.cc
SUBSCRIPTION

SUBSCRIBE TODAY AND GET A


FREE Raspberry Pi Pico W
Subscribe in print
today and get a FREE
development board WORTH

A brand new
RP2040-based
$6
Raspberry Pi Pico W
development board

Learn to code with


electronics and build
your own projects

Make your own


home automation
projects, handheld
consoles, tiny
robots, and much, This is a limited
offer. Not included
much more with renewals. Offer
subject to change or
withdrawal at any time.

Buy now: magpi.cc/subscribe

SUBSCRIBE
on app stores

magpi.cc 23
SUCCESS STORY

SUCCESS STORY magpi.cc/success

Sisyphus
Powered by Raspberry Pi, this mesmerising artwork
is an international hit. By Rosie Hattersley

A rtist Bruce Shapiro creates mesmeric


kinetic art that constantly undulates,
fascinating the viewer. He grew up
“enchanted by music, electronics, and making
things” and took tentative steps towards his own
in electronics and computing control led to a new
career. He became a solo kinetic artist and science
educator, using motion control technology to
create large scale installations for museums. (His
eye-catching artworks continue to be displayed in
N]PL_TZY^`^TYRXZ_Z]^Q]ZX`YbLY_POʮZ[[dOT^V museums and art galleries in Australia, Germany,
drives and a 286 computer. He quickly realised Switzerland, and USA.)
that discarded industrial automation parts could In 2015, Bruce created a new kinetic art table,
be picked up for peanuts via surplus outlets, and Sisyphus, again using CNC and polar stepper
_SL_.9.XLNSTYP^LYOXZ_Z]^bP]PPʬPN_TaPQZ] motors. This time, the precision CNC machine
motion-control tasks. that Bruce used to create cutouts for his kinetic
Bruce’s knack for creating kinetic art as a sculptures became a piece of art in its own right.
XPLY^ZQ^PWQPc[]P^^TZY_ZZVZʬLYOLQ_P] The Sisyphus Table took inspiration from the
originally working in medicine, his experiments legend of Sisyphus constantly pushing a boulder

24 magpi.cc Sisyphus
SUCCESS STORY

up a mountain: in Bruce’s work, a ball bearing


in place of a rock creates a constantly shifting
pattern on a layer of sand. A stepper-controlled
magnet underneath the sand table directs the
ball bearing’s motion. The robot controlling
everything, the Sisbot, used the same essential
OP^TRY-]`NPSLOTYaPY_POQZ]ST^ʭ]^_XZ_TZY
control device back in 1990.

THE CHALLENGE
There was plenty of interest in the design from the
art world and science museums, so Bruce founded
Sisyphus Industries and set about designing a
sand table with dual function as furniture and a
playable piece of art. Crowdfunding seemed an
obvious route. The choice of operating software
and hardware to drive it was less so – until Bruce
spoke to those he knew and trusted. “It was clear
that smaller, less expensive control hardware
would be needed.”

THE SOLUTION
Hardware costs, reliability, and community
support for the technology driving the kinetic table
led Bruce to consult his software engineer son,
the embedded software engineer he was working
with, and the younger members of the nearby
makerspace in Minneapolis. The vote for Raspberry
Pi was unanimous.
4_[]ZaPO_ZMPLRZZOʭ_?SP^LYO[WZ__P]

Sisyphus magpi.cc 25
SUCCESS STORY

thirty-somethings that I listen to,” says Bruce.


The community informed him that JavaScript is
essential and Node.js runs well on a Raspberry Pi.

THE RESULTS
“As a musical instrument plays songs, Sisyphus
plays paths,” the 2016 Kickstarter pitch explained.
The aim: to “get Sisyphus into peoples’ homes
for them to enjoy as both furniture and art, but
also, to inspire a community of composers to write
‘music’ for it.” The Sisyphus Sand Table became
– and remains – the most funded art project in
Kickstarter’s history, Bruce tells us, proudly.
Five years after launching Sisyphus Industries,
the company now has 15 full-time employees at its
Minnesota headquarters, and recently shipped its
ten-thousandth Sisyphus Table, with customers
across the globe and recent installations in Dubai
and Oslo.
mechanism, the Sisbot, needed to connect “Looking back over this time, our experience
to a custom two-motor driver board via USB using thousands of Raspberry Pis, including
serial port. Other output includes control of an 3B, 3B+, 3A+, and now 4, has been relatively
addressable RGBW LED strip. Inputs include seamless,” says Bruce. “Our software developers
_bZ3LWWPʬPN_SZXP^PY^Z]^LYOLYLYLWZR`P SLaPMPPYLMWP_Z]L[TOWdOP[WZdZ`]ʭ]XbL]P
signal from a phototransistor used to detect LN]Z^^OTʬP]PY_;TaP]^TZY^?SPSL]ObL]PSL^
ambient light levels (for auto-dimming the LEDs). proved highly reliable, both in the production
Raspberry Pi could do all of this. Both commercial QLNTWT_dLYOTY_SPʭPWO,YO_SPZ]TRTYLW]PL^ZY
we chose the
Raspberry Pi – its
Our experience using thousands of Raspberry vast community
– has proven to
Pis has been relatively seamless be invaluable in
recent experiments
and large-scale installation versions of Sisyphus using kinetic art within STEM education.
are controlled by Wi-Fi–connected Raspberry Pi
computers running JavaScript on Node.js.

WHY RASPBERRY PI?


In commercialising something that was previously
simply an art installation, issues of customer
support and maintenance became important.
In addition, some “painful” dead ends lead the
change-averse artist to look for a new means
of powering and controlling his Sisbot. “I don’t
like change when it comes to something that
works,” Bruce admits. “Through many trials, and
sometimes painful dead ends, I’ve learned that
community matters.”
It was the Raspberry Pi community that
convinced Bruce to switch over to a low-cost
microcomputer. “This was even more important
than form factor and low cost,” says Bruce.
“The choice to use Raspberry Pi in the new Images by Scott Streble used with permission. Other
home versions of Sisyphus was driven by all the images are by Sisyphus Industries

26 magpi.cc Sisyphus
Meet the
WIZnet Pico family
Experience the Power of Connectivity with WIZnet

● 3-in-1: TCP/IP Stack + MAC +PHY W51


00S-
EVB-
● Industrial grade operation range PICO
● RPi Pico pin-compatible
W55
00-E
VB-P
ICO

W61
00-E
VB-P
ICO

WIZn
COM et Et
ING S hern
WIZn OON et HA
et Pi T
co P
oE

● IEEE802.3af compliant
● Mode A(Endspan),
Mode B(Midspan)
● Circuit Protection (OV,OC)

Reseller suggestions Available at


and inquiries direct@wiznet.io WIZnet online store eshop.wiznet.io
FEATURE

Craft, control, and program


Python-powered robot arms and legs
By Danny Staple and Lucy Hattersley

28 magpi.cc Python Robots


FEATURE

R TYPES OF SERVO
ZMZ_^MPNZXPTYʭYT_PWdNZZWP]bSPY
L]X^LYOWPR^[ZbP]_SPX This feature
has them all, including walking dogs,
humanoid replicants, and grasping robot arms.
These robots all share one thing in common:
servo motors, also known as ‘servos’. This
type of motor rotates back and forth, unlike Servo motors are a type of motor that rotates
the DC motors of wheeled robots that spin back and forth with precision. They are used
endlessly around. in robots that require precise control, such as
robot arms and limbed dogs and walking bots.

This feature will equip The more expensive options include a sensor
of some kind to measure position. Here are
you with a real-world, some types of servo to look out for…

hands-on understanding of
articulated͸robotics SG (Servo Gear)
Dive into an enriching journey of Python Servo gear units like the SG90 and newer SG92 (£4/$4) are
programming and robotics with this feature. We inexpensive and light with precise movement control. The
will explain how servo motors work, how you can SG92R can rotate approximately 180 degrees (90 in each
control them in Raspberry Pi and look at some of HMVIGXMSR=SYƶPPǻRHXLIQMRIRXV]PIZIP
the fantastic robotic kits on the market. robotics projects where cost and
Whether you’re a hobbyist or an aspiring weight is a concern.
robotics expert, this guide will equip you with
a real-world, hands-on understanding of
articulated robotics. So it’s time to gear up, magpi.cc/sg92
assemble your tools, and embark on a thrilling
robotics adventure!

MG (Metal Gear) Brushless


The next step up in servos is to switch out the .REX]TMGEPQSXSVFVYWLIWEVIYWIHXSW[MXGL
plastic gears for metal. Servos such as this MG92 XLITSPEVMX]SJXLIQEKRIXMGǻIPH[LMGLMW
fSǺIVQSVIHYVEFMPMX]ERHWXVIRKXLXLER necessary for the motor to continue spinning.
XLIIRXV]PIZIP,QSHIPWERHEVIFIXXIV[LIVI -S[IZIVFVYWLIWEVIWYFNIGXXS[IEVERHGER
the servo is going to lift weights or move loads. GVIEXIIPIGXVMGEPRSMWIPMQMXMRKXLIPMJIWTERERH
They are a bit heavier and noisier than their performance of the motor. Brushless motors
plastic counterparts. PEWXPSRKIVYWIPIWWIRIVK]GVIEXIPIWWLIEXERH
make less noise while being faster with further
magpi.cc/mg90 VERKI8LI]GSWXEPSXQSVIXLSYKL

magpi.cc/brushlessservo

Python Robots magpi.cc 29


FEATURE

ROBOT KITS
MeArm Maker Kit
This is the kit that we are using to explain servo control for the main part of
XLMWJIEXYVI2I&VQ2EOIV fMWEZIV]PS[GSWXVSFSXEVQXLEXGERFI
assembled with just a hex key “and a dash of enthusiasm”. The kit includes
PEWIVGYXEGV]PMGTEVXWERHJSYVWIVZSQSXSVW.XƶWFEWMGFYXXLEXWMQTPMGMX]QEOIW
this a great place to start before moving on to more complex walking robots.

magpi.cc/mearmmaker

Marty v2
2EVX]XLI7SFSX: fMWEGLEVQMRKX[SPIKKIHVSFSXXLEXFVMRKW
GSHMRKXSPMJI)IZIPSTIHF]7SFSXMGEPMXJIEXYVIWPSXWSJEGGSQTER]MRK
educational projects and this friendly robot is controlled using Scratch
or Python. Robotical claims that it is suitable for children aged seven
ERHYTXSYRMZIVWMX]PIZIP2EVX]MWGSRXVSPPIHYWMRKGSPSYVIHGEVHW
ER&RHVSMHSVM5LSRIETTSV7EWTFIVV]5M)IWTMXIMXWGYXII\XIVMSV
2EVX]MWTEGOIH[MXLTSXIRXMEPQEOMRKMXEKVIEXXSSPJSVPIEVRMRKERHJYR

magpi.cc/marty

Petoi Bittle X
;IXIWXIH5IXSM'MXXPI fERHJSYRHMXXSFIEGYXI
TEPQWM^IHVSFSXHSKXLEXMWEKVIEXXSSPJSVTVSQSXMRK8*2
PIEVRMRK&RI['MXXPI<QSHIPMWMRJSVXIWXMRKERHRS[SǺIVW
voice interaction. It is a quad robot with four controllable
PIKWERHMXWTVMGIMWEQSVIEǺSVHEFPIEPXIVREXMZIXSLMKLIRH
robot pets. It comes with the NyBoard 1 controller board and
ten servo motors. It’s a delightful way to own a robot dog and
there are a lot of coding projects to be found here.

magpi.cc/petoibittle

30 magpi.cc Python Robots


FEATURE

Tony Pi
-M[SRHIVLEWMQTVIWWIHYW[MXLMXW[MHIVERKISJLMKLUYEPMX]
articulated robots. TonyPi (£453/$570) is a humanoid kit powered by
7EWTFIVV]5M','.XƶWRSXGLIETFYXXLIGSRWXVYGXMSRMWWYTIVF
ERHMXJIEXYVIWLMKLZSPXEKIFYWWIVZSW8LMWEHZERGIHVSFSXMW
HIWMKRIHXSTVSZMHIELERHWSRI\TIVMIRGIMR&.ERHVSFSXMGW
8SR]5MƶWGETEFMPMXMIWMRGPYHIMQEKIVIGSKRMXMSRERHXVEGOMRKQEOMRK
it a versatile tool for learning and exploration. Hiwonder provides an app
MRXIVJEGIERH]SYGERHMZIMRXSXLIOMXZME-ERHGSHIMXHMVIGXP]WSMXƶW
good for beginners and experts alike.

magpi.cc/tonypi

SpiderPi
8LI-M[SRHIVTMHIV5M fMWEWYFWXERXMEPVSFSXWXERHMRKRIEVP]GQSǺXLI
ground and spanning nearly 60cm when its legs are fully extended. Constructed with 18
WIVZSWWMQMPEVXSMXW-M[SRHIVWMFPMRKXLI8SR]5MXLITMHIV5MMWGSRXVSPPIHF]E,'7EWTFIVV]
5M8LMWLI\ETSHVSFSXJIEXYVIWER-)GEQIVEXLEXGERVSXEXIXLVSYKLHIKVIIWIREFPMRK
it to detect faces and signal recognition by waving a leg.
SpiderPi performs various movements including scuttling
JSV[EVHFEGOERHWMHI[E]WEW[IPPEWX[MWXMRKERHVEMWMRK
its front legs. Its camera and movement speed can be
adjusted via a sliding bar in the app. The robot can also
JSPPS[ERYRHYPEXMRKPMRISRXLIǼSSVHMWXMRKYMWL
FIX[IIRHMǺIVIRXGSPSYVIHSFNIGXWERHJSPPS[
commands issued via a Python script tied to a QR
code. It scared the bejesus out of our cat.
SUPER
SIMPLE
magpi.cc/spiderpi
ROBOTICS
We’ve got a guide
for newcomers to
robotics in issue

Mini Pupper 120 of The MagPi.


Unlike the articulated
wonders featured
2ERK)ERKƶW2MRM5YTTIV JVSQfMWERSTIRWSYVGI in this tutorial, our
earlier feature shows
ROS robot dog kit designed to make robotics more accessible. you how to create a
2ERK)ERKGPEMQW2MRM5YTTIVXSFIERI\GIPPIRXLERHW wheeled robot using
a few low-cost parts
SRXSSPJSV8*2ERH0IHYGEXMSR;MXLXLMWOMXPIEVRMRK and control it with
robotics becomes a fun and engaging journey. code. Wheeled robots
are much simpler, but
less fun.

magpi.cc/minipupper
magpi.cc/120

Python Robots magpi.cc 31


FEATURE

Control a robot arm


with Python
Build and control a robot arm,
while learning about how to
remotely control servo motors
on Raspberry Pi Pico W
By Danny Staple
DANNY
STAPLE
MAKER

Has a home robot


lab, making robots
with Raspberry
Pi and Pico as
Orionrobots. Degrees of freedom
Author of Robotics at the elbow,
±ƒƐBŇķåƭƾЃĚƐ
shoulder, and base
±žŤÆåŹŹDžƐ{Ğƭ{ĞÏŇ.

orionrobots.co.uk

YOU’LL
NEED
> MeArm Maker
magpi.cc/
mearmmaker
> Breadboard
A gripper uses a
magpi.cc/
fourth servo motor
breadboardhalf
> Jumper wires
magpi.cc/
jumperwires
> Laptop, tablet,
or smartphone
[MXLc;M+M

> &WQEPPGVSWWLIEH
screwdriver

> Thonny

32 magpi.cc Control a robot arm with Python


FEATURE

S
ervo motors allow your Raspberry Pi Pico
to control articulated robots, moving their Degrees of freedom
UZTY_^_Z^[PNTʭN[WLNP^
In this tutorial, you will learn where servo motors When talking about segmented robots,
can be used and how to connect a servo-driven like this arm, we use the term ‘degrees of
robot arm to a Raspberry Pi Pico W. freedom’, or DOF, to count the number of
You will learn how to use the asyncio library places or axes segments can move.
(XLR[TNNL^dYNTZ) to control servo motors
together, making articulated robotics possible.
You will then control this robot arm from a web
page or smartphone.

The MeArm uses four servo motors which allow


it to move in three axes and pick things up. The
What are servo motors?
01 Articulated robots use servo motors to
three degrees of freedom are a rotating base, a
shoulder joint, and an elbow joint. The axes are
control their joints. Servo motors combine a controlled by servo motors.
motor, a gearbox, and control circuits. They are
usually limited to 180 degrees of motion.
A servo motor uses closed circuit control and
Preparing Pico W
is controlled with pulse-width modulation
or ‘PWM’, where the length of pulses carries
03 Before we can interact with the arm, we
position information. need to prepare Raspberry Pi Pico W. First you
A Raspberry Pi Pico can output these signals, will need to solder headers onto it, unless you
with 65,536 possible values. Servo motors only
respond to a range of 8000 values, with very short
[`W^P^ _TXP^[P]^PNZYO?SP^P]aZʭYO^_SP
OTʬP]PYNPMP_bPPYT_^TY[`_LYOZ`_[`_[Z^T_TZY
The MeArm is an inexpensive,
_SPYXZaP^_SPXZ_Z]_Z]PO`NP_SPOTʬP]PYNP laser-cut robot arm kit

bought a model with pin headers on board. See


About the MeArm
02 The MeArm is an inexpensive, laser-cut
XLR[TNN^ZWOP]TYR for help with soldering.
You will also need the current version of
robot arm kit from Mime Industries (XTXPNZ`V). MicroPython for Raspberry Pi Pico W. Download
MeArm is designed for hobbyists and learners to the latest UF2 image from XLR[TNNXTN]Z[d_SZY.
build and program. Mime Industries has MeArm Hold the BOOTSEL button while connecting Pico W
models with electronics designed for Raspberry to a computer via USB; you can then drag and drop
Pi, Arduino, and micro:bit. However, the MeArm the UF2 image onto Pico W on the desktop.
Maker is a model which allows connection to any
controller, and will work well with Raspberry
Pi Pico.
Wiring servos to Pico W
04 ?SP^P]aZXZ_Z]^bTWWYPPO_ZMPNZYʭR`]PO
before assembling the arm. Unplug Raspberry
Pi Pico W from the USB port. Each servo motor

Alternative robots connects to one of the 3-pin connectors on the


MeArm board, with the orange or yellow wire
going to the pin marked O or Y on the board.
The techniques in this tutorial can be used
The 6-pin connector is wired to the Raspberry
JSVSXLIVEVXMGYPEXIHVSFSXWPMOI5IXSM'MXXPIc<
Pi Pico W. Plug the Pico W into a breadboard, and
the Hiwonder TonyPi, or for you to build a then run a jumper from each labelled connection
hexapod or robot tentacle!! on the 6-pin connector to the corresponding
breadboard row for the label on the Pico W.

Control a robot arm with Python magpi.cc 33


FEATURE

board. Leave the connections between the MeArm


board and Pico W. Building the arm is best
explained by the MeArm documentation, which
dZ`NLYʭYOL_XLR[TNNM`TWOTYRXPL]X.

Controlling arm movements


07 The code to control PWM for servo motors
is in a Servo class in XPL]X[d. It’s helpful to see
the servo motion as angles. We’ll make the middle
A selection of servo
Controlling servo motors with
motors. They come
MRHMǺIVIRXWM^IWXS
05 MicroPython
position 0, so the range is +/- 90.
The middle duty cycle value is 5000 for Pico
handle larger tasks.
The MeArm robot Plug in the Pico W, then open Thonny. MicroPython – we’ll call this PWM_MID. If we take
uses tiny ones Connect Thonny to the Pico W, and start the +/- 4000 as the range from this position, we
MicroPython Shell. can divide 4000 by 90 to get a DEGREES_TO_PWM
Type the following lines: scale factor.
We can then multiply an angle by this scale
import machine factor and add the result to the PWM_MID to get the
grip = machine.PWM(machine.Pin(4, machine. duty cycle.
Pin.OUT))
grip.freq = 50
grip.duty_u16(5000)
Making an arm from Servos
5000 corresponds to the middle position for the
08 The Arm class uses the Servo class for each
motor. You can try other values and should see the joint. The Arm class has default pin numbers
motor spin. However, ensure it is at position 5000 NZ]]P^[ZYOTYR_Z_SPbT]TYRM`_bT_SOTʬP]PY_[TY
MPQZ]PʭYT^STYR_ST^^_P[ numbers, it allows two or more arms!
Repeat this for the other three servo motors on Load XPL]X[d in Thonny and hit the play
pins 5, 6, and 7. Avoid turning servo motors by button. You’ll return to the MicroPython Shell.
hand, as this is likely to break gears inside them. Type arm.base.set_angle(-30), to move the arm
base to -30 degrees. You can try this with every
joint. Find the limits by increasing numbers out
from the 0 position in 5-degree steps until the
Assembling the MeArm Maker
06 With the Pico still powered, follow the
joint doesn’t move again, then go back a step.
Don’t leave a joint past these limits in order to
MeArm instructions linked below for attaching avoid damage.
servo horns while the servo motors are in the
middle position. You can play with servo motor
positions here, but ensure you return them to
Smoother motion
position 5000 before assembling.
Next, unplug the USB connection to the Pico,
09 The servos are jumping, but we can make
then unplug the servo motors from the MeArm them smooth. In Servo.move, we control speed

This chart displays


5;2 TYPWI[MHXL
modulation) signals.
Shaded parts show a
high signal. Shorter
pulses pull the servo
anticlockwise, mid
pulses go to the
middle, and long
pulses go clockwise

34 magpi.cc Control a robot arm with Python


FEATURE

and smoothness with a time in seconds and with


a step count.
The Servo class stores a current position;
Servo.move ^P_^L_L]RP_LYORP_^_SPOTʬP]PYNP
between this and the current position.
Servo.move divides the time by steps for
step_time LYOOTaTOP^_SPXZaPXPY_OTʬP]PYNPMd
steps for step_size.
It loops over the steps, adding the step_size to
the current position, moving the servo to this new
position, and sleeping step_time.
In the Shell, type do(arm.elbow.move(30)) to see
the elbow move smoothly to 30 degrees.

Moving joints together


10 Moving joints together is more interesting. with Tools > Manage packages. Search for A servo usually
has three pins:
We used a do helper around Servo.move because microdot, then click Install. ƵƶJSVZSPXEKIƵƶ
for ground, and a
move is asynchronous. When it encounters the When you run bPMJL]X[d, it will look for a yellow or orange
await instruction, other code can run, enabling us connection. Once it has connected, it will print the 5;2MRTYXWMKREP

to do multiple tasks at the same time. network address of your Pico W to the console.
The move_together method in Arm sets up a

Building arm control endpoints


It’s helpful to see the servo 12 The microdot web server lets us build tiny

motion as angles endpoints to control our arm. There is a microdot


app object, which lets us set a link between an
incoming request path and a Python function,
for example linking /set_grip/<position> to the
XZaPXPY__L^VQZ]PLNS^[PNTʭPOUZTY_[Z^T_TZY function set_grip. The <position> [L]_^[PNTʭP^L
and then uses await uasyncio.sleep(seconds) to position parameter which the function can use and
wait for all the move tasks to complete. The tasks pass to the arm.
all get time to run, so things can move together. These functions are also in async, so the server
Try do(arm.move_together(base=40, can handle requests while the arm is still moving.
shoulder=20, grip=30, base=50)) to see Upload ^PN]P_^[d, XPL]X[d, and bPMJL]X[d to
everything move at the same time! Perhaps we Pico W, then click the run button on bPMJL]X[d
could do something else? to start the server.

Connecting to the network Trying the endpoints


11 We can connect our Pico W to a Wi-Fi
13 Point a web browser at the address you
network. Add a ^PN]P_^[dʭWPZY_SP;TNZbT_S were shown in Step 11 plus a movement to make.
your SSID and Wi-Fi key. For example: S__[%$!#!^P_JPWMZb
to move the elbow to 30 degrees.
SSID = "<network name>" You do not have to wait for a previous
PSK = "<network password>" XZaPXPY__ZʭYT^SMPQZ]P^PYOTYRXZ]P
movement instructions to the robot. It will not
?SP_Z[ZQ_SPʭWP bPMJL]X[d imports these behave correctly if you try to move the same motor
secrets and uses them to connect to your Wi-Fi. _bTNPMPQZ]PT_ɪ^ʭYT^SPO_SZ`RS?ST^T^:6M`_
We will also be using the microdot web server for it’s not the most enjoyable way to interact with
MicroPython. You can install this from Thonny the robot.

Control a robot arm with Python magpi.cc 35


FEATURE

The techniques in
this article can be
used to control the
ten servo motors
on the Petoi Bittle X
robot dog

Connecting the sliders


There’s another endpoint in bPMJL]X[d,
named / and connected to an index function which
15 In NZY_]ZWS_XW, it loads jquery, a
serves a page to control the arm. JavaScript library designed to help with handling
page events and sending data from a page.
When the document is ready, our JavaScript
searches for the input elements, and links on
Putting sliders on a web page
14 The index function loads a NZY_]ZWS_XW
change handlers for each of them.
Focusing on the shoulder element, when this
ʭWPLYO^PYO^_ST^MLNV?SPMZOdZQNZY_]ZWS_XW input is changed, the function will send a GET
has a title, and four input type="range" elements.
Each range input lets you specify the minimum,
maximum and starting values.
The datalist element snap_to_zero is used for the
You can drag sliders around to
list property of the ranges to draw markers at 0. move the arm positions
The page has a style section, overflow: hidden,
that stops the page being accidentally scrolled
on a phone, The width and height settings make request to the bPMJL]X[d server. This goes to
_SP^WTOP]^ʭ_bPWWZYLYd^N]PPYLWZYRbT_S_SP ^P_JML^P and combines it with the value of the
;MVMRKXLI2I&VQXS
7EWTFIVV]5M5MGS; viewport setting in the page head. shoulder element. The change event happens when
;MVIWKSFIX[IIR
labels with the
If you go to the address of your Pico W, you LYTY[`_ZY_SP[LRPT^XZaPOLYO_SPʭYRP]Z]
same name should see the four sliders. mouse button is lifted. This means you can drag
sliders around to move the arm positions. You can
connect with a smartphone to drive this too!

Recording steps
16 At the bottom of the page, there are buttons
to add movement steps. In the HTML, they have
onclick handlers to call into bPMJL]X[d.
When the ‘add step’ button is clicked,
bPMJL]X[d collects the current position of each
servo motor, and stores this set of positions in
the variable step_list. Then, when ‘run steps’ is
clicked, an async task calls move_together with
each set of positions, playing the whole list back.

36 magpi.cc Control a robot arm with Python


FEATURE

There are also save/load buttons. These will joints to 0 and press ‘add step’. Setting out markers
for the arm to pick up
^_Z]P_SP^_P[^TYL5>:9ʭWPZY;TNZB^ZdZ`NLY 4QdZ`[`__SPZMUPN_MLNVZY_SPʭ]^_XL]VP] and move objects to
load steps back later. and press the ‘run steps’ button, the robot will
now automatically pick up the object and move
it to the other marker. You can use the ‘save
steps’ and ‘load steps’ buttons to save this
Fun with recorded steps
17 Put the robot on the long side of a sheet
for demonstrations!

of paper. Draw a line in front of the base to align


the arm’s base. Draw a mark between 30 and 60
What to do next?
degrees to the left and 100 to 140 mm from the
base of the arm, and another mark to the right.
18 Connecting the gripper servo motor power
Place a light object, like a small eraser, on one through a current sensor, like an INA219, means
mark. Using the web interface, open the grippers, you could detect when the grippers are holding
rotate the arm to face the object, then move the something by closing them until current goes
arm so the object is between the open grippers. above a threshold.
Press the ‘add step’ button. Close the grippers, and Articulated robots use inverse kinematics to
press ‘add step’. calculate servo angles based on a desired position.
Now set the elbow, base, and shoulder joints to Adding this would make it easier to position the
0 and press ‘add step’. Then move the base, elbow, arm from the controls.
and shoulders to put the object on the other mark You could add a distance sensor to the front of
and add a step. Open the grippers, then add a step. the arm, move the base to scan for the object, and
Now move the elbow and shoulders up, and add combine this with inverse kinematics to position
a step. Finally, set the elbow, base, and shoulder the grips for an arbitrarily placed object.

Control a robot arm with Python magpi.cc 37


FEATURE

DOWNLOAD
mearm.py THE FULL CODE:
> Language: MicroPython magpi.cc/mearmpy

001. """ 031. for n in range(steps):


002. import sys 032. await uasyncio.sleep(step_time)
003. del sys.modules["mearm"] 033. self.set_angle(self.current)
004. from mearm import arm, do 034. self.current += step_size
005. # tests 035.
006. 036.
007. do(arm.move_together(base=30, shoulder=40, 037. class Arm:
elbow=30, grip=20)) 038. def __init__(self, elbow_pin=4, grip_pin=5,
008. do(arm.move_together(shoulder=0, elbow=-30)) shoulder_pin=6, base_pin=7):
009. """ 039. self.grip = Servo(grip_pin)
010. import machine 040. self.elbow = Servo(elbow_pin)
011. import uasyncio 041. self.shoulder = Servo(shoulder_pin)
012. 042. self.base = Servo(base_pin)
013. 043.
014. PWM_MID = 5000 044. async def move_together(self, base=None,
015. PWM_FREQ = 50 shoulder=None, elbow=None, grip=None, seconds=1,
016. DEGREES_TO_PWM = 4000 / 90 steps=100):
017. 045. if base is not None:
018. 046. uasyncio.create_task(self.base.move(
019. class Servo: base, seconds=seconds, steps=steps))
020. def __init__(self, pin): 047. if shoulder is not None:
021. self.pwm = machine.PWM(machine.Pin(pin, 048. uasyncio.create_task(self.shoulder.
machine.Pin.OUT)) move(shoulder, seconds=seconds, steps=steps))
022. self.pwm.freq(PWM_FREQ) 049. if elbow is not None:
023. self.current = 0 050. uasyncio.create_task(self.elbow.
024. move(elbow, seconds=seconds, steps=steps))
025. def set_angle(self, angle): 051. if grip is not None:
026. self.pwm.duty_u16(int(PWM_MID + ( 052. uasyncio.create_task(self.grip.
angle * DEGREES_TO_PWM))) move(grip, seconds=seconds, steps=steps))
027. 053. await uasyncio.sleep(seconds)
028. async def move(self, position, seconds=1, 054.
steps=100): 055.
029. step_time = seconds/steps 056. arm = Arm()
030. step_size = ( 057. do = uasyncio.run
position - self.current) / steps

38 magpi.cc Control a robot arm with Python


FEATURE

web_arm.py
> Language: MicroPython

001. import machine uasyncio.create_task(arm.elbow.


002. import uasyncio 047. move(int(position)))
003. import json 048. return 'Moving'
004. 049.
005. from microdot_asyncio import Microdot 050. @app.route('/add_step')
006. from mearm import arm 051. async def add_step(request):
007. 052. state = (arm.base.current, arm.shoulder.
008. import network current, arm.elbow.current, arm.grip.current)
009. from utime import sleep 053. step_list.append(state)
010. 054. return 'Added step'
011. from secrets import * 055.
012. 056. async def run_steps():
013. def wiº_connect(): 057. try:
014. wlan = network.WLAN(network.STA_IF) 058. for step in step_list:
015. wlan.active(True) 059. await arm.move_together(
016. wlan.connect(SSID, PSK) *step, seconds=1)
017. while wlan.isconnected() == False: 060. except:
018. print('Waiting for connection...') 061. print("Steps were:", step_list)
019. sleep(1) 062. raise
020. print(wlan.ifconºg()) 063.
021. 064. @app.route('/run_steps')
022. app = Microdot() 065. async def handle_run_steps(request):
023. step_list = [] 066. uasyncio.create_task(run_steps())
024. 067. return 'Running steps'
025. @app.route('/') 068.
026. async def index(request): 069. @app.route('/save_steps')
027. with open("control.html") as content: 070. async def handle_save_steps(request):
028. return content.read(), 200, { 071. with open("steps.json", "w") as f:
'Content-Type': 'text/html'} 072. json.dump(step_list, f)
029. 073. return 'Saved steps'
030. @app.route('/set_grip/<position>') 074.
031. async def set_grip(request, position): 075. @app.route('/clear_steps')
032. uasyncio.create_task( 076. async def handle_clear_steps(request):
arm.grip.move(int(position))) 077. step_list.clear()
033. return 'Moving' 078. return 'Cleared steps'
034. 079.
035. @app.route('/set_base/<position>') 080. @app.route('/load_steps')
036. async def set_base(request, position): 081. async def handle_load_steps(request):
037. uasyncio.create_task(arm.base.move( 082. global step_list
int(position))) 083. with open("steps.json") as f:
038. return 'Moving' 084. step_list = json.load(f)
039. 085. return 'Loaded steps'
040. @app.route('/set_shoulder/<position>') 086.
041. async def set_shoulder(request, position): 087. try:
042. uasyncio.create_task(arm.shoulder.move( 088. wiº_connect()
int(position))) 089. print("Starting app")
043. return 'Moving' 090. app.run(port=80)
044. 091. except KeyboardInterrupt:
045. @app.route('/set_elbow/<position>') 092. machine.reset()
046. async def set_elbow(request, position):

Control a robot arm with Python magpi.cc 39


TUTORIAL

State of Play:
Game Engines
for Raspberry Pi
Develop anything from text adventures to 3D
worlds with four sophisticated game engines

Y
ou don’t need a fancy integrated aarch64 hardware like Raspberry Pi 4’s, game
development environment (IDE) or engine support for the platform has expanded
graphical engine to create fantastic ^TRYTʭNLY_Wd^TYNPbPWL^_Pc[WZ]POZ`]Z[_TZY^
K.G.
MAKER

Orphanides computer games, but they really can help. With for game development. We’re going to highlight
mature choices of 64-bit operating system for four of the most exciting game engines you
K.G. is a software Raspberry Pi and enthusiasm among developers can use to make your own games on Raspberry
preservationist and for releasing software to support Linux on Pi today.
developer who’s
written middling

Godot 3.5
text adventures
for fun and done magpi.cc/godot35
despicable things
to 3D engines
JSVTVSǻX 64-bit? Yes has comprehensive documentation with some fantastic
32-bit? Yes tutorials to get you started – just make sure you’re
magpi.cc/owlbear
following the docs (magpi.cc/godotdocsšüŅųƴåųŸĜŅĹƐţĂţ
Godot is a free, open-source game engine for 2D and 3D
games. In fact, it’s one of your few fully functional choices Install it:
for 3D games development on Raspberry Pi, and includes Download the latest release for your Raspberry Pi from
a full IDE in the vein of Unity and Unreal Engine. That said, magpi.cc/godotrpi.
the editor does chug a bit with a reasonably busy 3D ŽĹDŽĜŞĜƋ±ĹÚųƚĹƋĘåųåĬåƴ±ĹƋƴåųŸĜŅĹţ
scene loaded in, so you might want to stick to 2D, or only
the simplest 3D scenes, if Raspberry Pi is your primary Notable works:
development system. ųŅƋ±ƋŅرŸŸåƋƋå屟ƋŸØųƚåĬƋƼ„ŧƚ±ÚØ{:ĜűŅƻţ

œåųåÏŅĵĵåĹÚƋĘåŽĹŅþÏĜ±Ĭ:ŅÚŅƋüŅų±ŸŞÆåųųƼ{Ĝ
port. On the downside, this means you’re limited to
:ŅÚŅƋƤƐØų±ƋĘåųƋʱĹƋĘåŸĬĜčĘƋĬƼŸĹ±DŽDŽĜåų:ŅÚŅƋĉţ‰Ęå
latter can also be built for Raspberry Pi, but there isn’t
currently a consistent deployment path for this, so it’s
ÆåŸƋƋŅŸƋĜÏĩƵĜƋĘƋĘåŽĹŅþÏĜ±Ĭ:ŅÚŅƋŞŅųƋŅüƐţĂüŅų
ŸƋ±ÆĜĬĜƋƼţŅƋĘ:ŅÚŅƋĉ±ĹÚƋĘ屟ŞÆåųųƼ{ĜŞŅųƋŅü:ŅÚŅƋ
ƐţñĬĬŅƵƼŅƚƋŅƋ±ųčåƋƼŅƚųč±ĵåÆƚĜĬÚŸ±Ƌ±ŸŞÆåųųƼ{Ĝţ

By default, Godot uses its own GDScript language, a


high-level, object-oriented language with Python-like
syntax. It’s very quick to learn and is, in fact, your only
Godot is a full 2D/3D game engine and integrated
option in this Raspberry Pi port, although other versions development environment. Everything works, though
Ņü:ŅÚŅƋŅýåųŅŞƋĜŅűĬŸƚŞŞŅųƋüŅųńØرĹÚťťţ:ŅÚŅƋ 3D scenes can run slow when you play them

40 magpi.cc State of Play: Game Engines for Raspberry Pi


TUTORIAL

Twine allows you


to create complex
choice-based
games. Minimal
programming is
required, but you can
create surprisingly
complex routines
using story formats
like Harlowe

Twine twinery.org

64-bit? Yes „ƚč±ųƚÆåĜŸƋĘåÏŅĹƋĜĹƚ±ƋĜŅĹŅü‰ƵĜĹåűŸĀųŸƋŸƋŅųƼ


32-bit? No üŅųĵ±ƋرĹÚÆåĹåĀƋŸüųŅĵ±ĵ±Ƌƚųåĵ±ÏųŅĬ±Ĺčƚ±čåſ
ʱŞÆŅŅĩĜŸ±ĵŅųåůĬĜƋåų±ųƼű±ĹÚčåĹåų±ĬĬƼÆŅŅĩěĬĜĩå
Twine is one of the most approachable ways of making story format, great for making traditional choice-based
a text game, allowing you to create choice-based books, and good for authors without any programming
ĜĹƋåų±ÏƋĜƴåĀÏƋĜŅűĹÚÏĘŅŅŸåěƼŅƚųěŅƵĹě±ÚƴåĹƋƚųå knowledge. Snowman is a bare-bones but highly
narratives. It’s based on HTML and JavaScript, making it customisable story format designed for developers who
easy to publish your games online and even extend the ±ųå±Ĭųå±ÚƼÏŅĵüŅųƋ±ÆĬåƵĜƋĘI±ƴ±„ÏųĜŞƋ±ĹÚ„„ţ
features of the game engine, which by default supports
ŸŅƚĹÚØĜĵ±č埱ĹÚƴĜÚåŅØģƚŸƋ±ŸB‰aXĂÚŅåŸţ Whichever story format you choose, Twine’s
development interface presents you with a series of
Twine has made its mark in the world of interactive interlinked boxes, each containing a passage of text that
ĀÏƋĜŅĹŅƴåųƋĘåƼå±ųŸØʱŸÆåÏŅĵåŅĹåŅüƋĘåĵŅŸƋ you can think of as a paragraph, a page, or a location
ŞŅŞƚĬ±ųåĹčĜĹåŸĜĹƋĘåF8ŅĵŞÏŅĹƋåŸƋØÆååĹƚŸåÚÆƼ ĜĹƼŅƚų±ÚƴåĹƋƚųåč±ĵåØ¥ŅƚųĀĹĜŸĘåÚč±ĵåƵĜĬĬÆå
narrative designers and game writers as a prototyping ŸŞ±ƋŅƚƋ±Ÿ±ĹB‰aXĂŞĬƚŸI±ƴ±„ÏųĜŞƋåƻŞåųĜåĹÏåƋʱƋ
±ĹÚŞĬŅƋƋĜĹčƋŅŅĬĜĹĬ±ųčåųŞųŅģåÏƋŸØ±ĹÚʱÚ±ŸĜčĹĜĀϱĹƋ can be played via a web browser – just upload it to
ŞųåŸåĹÏåĜĹƋĘåX:‰}ťč±ĵåŸĵŅƴåĵåĹƋŅüƋĘåƖLjŎLjŸţ ƼŅƚųƵåÆŸĜƋå±ĹÚŸĘ±ųåƋĘåĬĜĹĩţeĹƚĵÆåųŅüƋŅŅĬŸ
We’ve been running Twine on Raspberry Pi for years, and wrapper techniques exist to turn your web-based
starting with Raspberry Pi 3 running a 32-bit operating č±ĵåĜĹƋŅ±ŸƋ±ĹÚě±ĬŅĹåŅÿĜĹååƻŞåųĜåĹÏåرĬƋĘŅƚčĘ
ŸƼŸƋåĵţ‰ĘĜĹčŸʱƴåĵŅƴåÚŅĹŸĜĹÏåŅƚųƖLjŎƅƋƚƋŅųĜ±ĬØ that’s not the primary focus of the engine. Indie
Ƶ±ƼƱÏĩĜĹĜŸŸƚåƅĉţeĬƋĘŅƚčĘŅƚųčƚĜÚåƋŅÚåƴåĬŅŞĜĹč game distribution platform itch.io directly supports
for Twine’s Harlowe language is still relevant to modern Twine games.
versions, Twine’s IDE has seen some welcome polish in
recent years. Install it:
±ŸŞÆåųųƼ{ĜƚŸåųŸųƚĹĹĜĹč±ƅĉěÆĜƋŅŞåų±ƋĜĹčŸƼŸƋåĵ
‰Ęåųå±ųåüŅƚųÆƚĜĬƋěĜĹŸƋŅųƼüŅųĵ±ƋŸ×ʱŞÆŅŅĩØ should go to twinery.orgØÏĬĜÏĩů%ŅƵĹĬŅ±ÚÚåŸĩƋŅŞ±ŞŞűØ
B±ųĬŅƵåØ„ĹŅƵĵ±ĹرĹÚ„ƚč±ųƚÆåţ¥ŅƚųÏĘŅĜÏåŅü ŸåĬåÏƋƋĘåXĜĹƚƻě±ųĵƅĉƴåųŸĜŅĹØƚĹDŽĜŞĜƋرĹÚųƚĹƋĘåĀĬå
story format determines the appearance, behaviour, named twine from a terminal with ./twine.
and syntax of your Twine creations. Harlowe is
the beginner-friendly default format and our Notable works:
recommendation for anyone starting with Twine, as it’s Depression Quest, This Book is a Dungeon, Horse
ÆŅƋĘ屟ƼƋŅƚŸå±ĹÚāåƻĜÆĬååĹŅƚčĘƋŅ±ĬĬŅƵƼŅƚƋŅ Master: The Game of Horse Mastery, Black Mirror:
easily bolt on additional functionality. Bandersnatch (development).

State of Play: Game Engines for Raspberry Pi magpi.cc 41


TUTORIAL

Inform 7 is a mainstay

Inform 7
of the creative
MRXIVEGXMZIǻGXMSR
community and
magpi.cc/inform
has also been used
for commercial
titles such as 64-bit? Yes interpreter. To get started playing Glulx games, open a
Andrew Plotkin’s
Hadean Lands
32-bit? No terminal and type sudo apt install gargoyle-free.

FĹüŅųĵĜŸŅĹåŅüƋĘåÆåŸƋěĩĹŅƵĹĜĹƋåų±ÏƋĜƴåĀÏƋĜŅĹ If you fancy something a bit more traditional, or if you’re


languages, and version 7 is the pinnacle of its ±ĹĜĹƋåų±ÏƋĜƴåĀÏƋĜŅĹÚåƴåĬŅŞåųƵŅųĩĜĹčĜűĬ±Ĺčƚ±čå
development: a natural-language text adventure ŅƋĘåųƋʱĹ)ĹčĬĜŸĘØFĹüŅųĵƅŠgithub.com/DavidKinder/
±ƚƋĘŅųĜĹčŸƼŸƋåĵĜĹ)ĹčĬĜŸĘſƋŅÏųå±Ƌ屟ޱÏåüŅų Inform6) is a viable alternative, with a compiler that runs
ŞĬ±ƼåųŸƋŅĜĹƋåų±ÏƋƵĜƋĘØƼŅƚƋƼŞåŸŅĵåƋĘĜĹčĬĜĩåů‰Ęå ŅűŸŞÆåųųƼ{ĜţBŅƵåƴåųØFĹüŅųĵƅĬ±ÏĩŸƋĘåĜĹƋåčų±ƋåÚ
Shed is a room,’ followed by its description. Interactive development environment of its latest successor. The
ŅÆģåÏƋŸ±ĹÚÏʱų±ÏƋåųŸ±ųåÚåĀĹåÚĜűŸĜĵĜĬ±ųƵ±Ƽţ IDE, with its area maps and comprehensive integrated
kŞåĹěŸŅƚųÏåÚĜĹƖLjƖƖØFĹüŅųĵƀ±ĬĬŅƵŸƵųĜƋåųŸƋŅƚŸå authoring guide, helps to set Inform 7 apart from both
the familiar milieu of words to develop games with its predecessors and many of its rivals.
complex functions and rich interactivity.
Install it:
The Inform 7 IDE is an immensely useful tool. It’s set sudo apt install flatpak
up with two pages, containing your game’s script on flatpak remote-add --if-not-exists flathub
ƋĘåƤĬåüƋţţ https://flathub.org/repo/flathub.flatpakrepo
flatpak install inform
FĹüŅųĵƀϱĹŅƚƋŞƚƋ¬ěa±ÏĘĜĹåŸƋŅųƼĀĬåŸØƋĘåÚåü±ÏƋŅ
ĜĹƋåų±ÏƋĜƴåĀÏƋĜŅĹÏŅĵĵƚĹĜƋƼŸƋ±ĹÚ±ųÚØÏŅĵޱƋĜÆĬåƵĜƋĘ Select app/com.inform7.IDE/aarch64/stable (option 2
the virtual machine used by legendary text adventure at the time of writing) and type Y to install it.
ÚåƴåĬŅŞåųFĹüŅÏŅĵĜĹč±ĵ域ƚÏʱŸ¬ŅųĩſŅų:ĬƚĬƻ eŞŞųŅƴå±ĹƼŅƋĘåųųåŧƚĜųåÚÏʱĹčåŸƋŅĜĹŸƋ±ĬĬ
ĀĬåŸØƵĘĜÏʱųåƱŸåÚŅŬěŅÚåÆƚƋƵĜƋĘŅƚƋƋĘåŅĬÚåų dependencies by typing Y.
ŸƋ±ĹÚ±ųÚűŸƅĉĩĵåĵŅųƼĬĜĵĜƋ±ƋĜŅĹţŽĹĬ域ƼŅƚűųå Inform 7 will be added to the main menu’s
ޱųƋĜÏƚĬ±ųĬƼÏŅĵĵĜƋƋåÚƋŅĉLjƼå±ųŸűƵŅųƋĘŅüƱÏĩƵ±ųÚŸ Programming section.
compatibility, we recommend opting for Glulx. Glulx
interpreters for Raspberry Pi include Gargoyle, Notable works:
ScummVM, and the browser-based Parchment eĹÏĘŅųĘå±ÚØŅƚĹƋåųüåĜƋaŅĹĩåƼØB±Úå±ĹX±ĹÚŸţ

42 magpi.cc State of Play: Game Engines for Raspberry Pi


TUTORIAL

Ren’py is the engine


underlying numerous
very polished
commercial visual
novels, such as
Maxi Molina’s The
Hayseed Knight

Ren’py renpy.org

64-bit? Yes (run 32-bit version) Raspberry Pi 3 can run most Ren’Py games, allowing
32-bit? Yes you to develop for the platform, but may struggle with
Ren’py’s graphical launcher, depending on your OpenGL
If you’ve played a modern indie visual novel (VN), it was settings. This isn’t required to develop your games,
probably made using Ren’py, a specialist game engine however, as you’ll be spending most of your time using
built on top of Python, with a range of almost-natural- ƼŅƚųŞųåüåųųåÚåÚĜƋŅųţœåƚŸåš„ŅÚåƵĜƋĘƋĘååĹű{Ƽ
language functions designed to do the kind of things Language extension installed. You can use Ren’Py to
you’d expect in a visual novel: load a background scene, develop kinetic visual novels – those that involve no
show a character, place some building, and display interaction from the reader beyond moving to the next
narrative text or dialogue. It’s elegant, and the core page – as well as VNs with choice-based gameplay and
functions have been kept simple, aided by a superb branching dialogues, and even those that incorporate
quickstart guide. This makes it a particularly good elements of other genres, such as RPG-style combat or
choice for artists who wish to start developing their the minigames we mentioned above.
own games.
One last thing to bear in mind when looking for Ren’py
But you can extend its normal capabilities and features games and sample code is that it’s hugely popular
with your own Python scripts, invoked directly from for creating adults-only erotic visual novels, and even
within Ren’py. For example, if you want to add health works that don’t feature any sexual content often
and combat mechanics to your VN, you’ll want to turn ƋŅƚÏĘŅĹĵ±ƋƚųåƋĘåĵåŸţeƚƋĘŅųŸ±ųåčåĹåų±ĬĬƼčųå±Ƌ
ƋŅ{ƼƋĘŅĹţFĹü±ÏƋØ{ƼƋĘŅĹĵ±ĩåŸåĹűŞƼŸŅāåƻĜÆĬåƋʱƋ about providing appropriate warnings about sexual and
developers are sharing code for minigames ranging mature content, but it’s worth bearing in mind if you’re
üųŅĵčŅ±ĹÚŸŅĬĜƋ±ĜųåƋŅĀŸĘĜĹč±ĹÚĬŅÏĩŞĜÏĩĜĹčţ looking for examples to share with younger developers.

œĜƋĘåĹű{ƼíØƋĘååĹƋĜųååĹčĜĹåʱŸĵŅƴåÚƋŅ{ƼƋĘŅĹƤƐØ Install it:


ĀƻĜĹč±ĹƚĵÆåųŅüĬŅĹčŸƋ±ĹÚĜĹčĜŸŸƚåŸØŸƚÏʱŸŞŅŅų Go to renpy.org and click on the button to download
handling of accenting and non-Latin characters. Even the version you want – at the time of writing, the latest
ƋĘŅƚčĘåĹűŞƼűŸŅþÏĜ±ĬÚŅÏƚĵåĹƋ±ƋĜŅĹĜŸƵųĜƋƋåĹƋŅ ƴåųŸĜŅĹĜŸåĹű{ƼíţŎţLjţ
manage your expectations of the engine’s ability to run „åĬåÏƋƋĘåů%ŅƵĹĬŅ±ÚeaXĜĹƚƻŠ±ŸŞÆåųųƼ{Ĝ±ĹÚ
on Raspberry Pi, we found that Ren’py runs in full, with ĘųŅĵåÆŅŅĩš„%UűĬĜĹĩØƚĹDŽĜŞĜƋرĹÚųƚĹrenpy.sh.
ĹŅĜŸŸƚåŸØŅűŸŞÆåųųƼ{ĜĉÏŅĵŞƚƋåųŸųƚĹĹĜĹčåĜƋĘåų
ƐƖěÆĜƋŅųƅĉěÆĜƋXĜĹƚƻŅŞåų±ƋĜĹčŸƼŸƋåĵŸØƋʱĹĩŸƋŅ± Notable works:
ÚåÚĜϱƋåÚeaXĜĹƚƻÆƚĜĬÚţ ‰ĘåB±ƼŸååÚUĹĜčĘƋØXŅųåʼnĘåeĵ±DŽŅĹ{ųĜĹÏ域ØXŅĹč
XĜƴå‰Ęå}ƚååĹØ}%e%ţ

State of Play: Game Engines for Raspberry Pi magpi.cc 43


TUTORIAL

Build a classic
text adventure
in Inform
Get started in interactive fiction development

I
nform can be used to create very traditional OTʬP]PY_NZY_PY_TYNW`OTYRPc_PY^TZY^^P__TYR^
Top Tip quest-based text adventures, sprawling and
TY_]TNL_PbZ]V^ZQRPY]PʭN_TZYTY_P]LN_TaP
and a map of your previous play-throughs. A play
button just above the right-hand pane allows
theatre, and experimental art games. You can you to play your game. Note the circle arrow
Sentence
add graphics and sound, and a range of extensions next to it: this will replay every command you
structure
(XLR[TNNTY_ʭN) have been released by the typed in your previous play-through, allowing
eĬƋĘŅƚčĘƵåűƴå community to add features and functionality. you to immediately see the impact of changes to
organised As an introduction to Inform 7’s language and your code.
our code in capabilities, we’re going to create a simple escape
successive
room puzzle, with a couple of locations and a
lines for ease
handful of objects. In The Shed of Mystery, the
of reading,
Create a room
Inform will
cheerfully accept
player’s going to have to work out how to escape a
garden shed. You will need a 64-bit installation of
02 We’ll start by creating and describing a
paragraphs. =L^[MP]]d;T:>_Z]`Y_SP4YQZ]X"ʮL_[LV room. Type the following:
The Shed is a room. ‘A cluttered wooden
shed, lined with shelves and smelling faintly
of creosote.’
Your new adventure
01 Open Inform 7 and click ‘Start a new
?SPʭ]^_]ZZX_SL_L[[PL]^TYdZ`][]ZUPN_T^
where your player will start the game by default,
project’. Click Next to create a new story. Select but you can always override this with a line
or create a directory for your project to live in. reading ‘The player is in [the room you wish them
Inform’s ‘skein’ Enter your game’s name and your own, then click to start it]’ at the beginning.
records every Next. Check your project settings, and click Apply. To help with larger games, you can also group
sequence of actions
you’ve played Inform’s main interface opens with an editor Rooms into Regions, and create Scenes, which
through, illustrating
on the left and a documentation pane on the NLYTYNW`OP^N]T[_POLN_TZY^Z]^[PNTʭNTYRLXP
paths through
your game right. Tabs on both let you switch between time periods.

Your first objects: Supporters


03 To create an object in Inform 7, you start by
naming it. Type:
A workbench is here. The workbench is a
supporter. Instead of examining the workbench,
say ‘The old workbench is almost, but not
entirely, free of mess.’
That’s created an object called workbench and
OPʭYPOT_L^Lɩ^`[[Z]_P]ɪLYZMUPN_bSTNSNLY

44 magpi.cc Build a classic text adventure in Inform


TUTORIAL

It’s a good idea to give all your Inform projects their


own directories, just to keep everything tidy

have other objects on top of it. Pay attention to


that ‘instead of examining’ phrase. If we’d just
given the workbench a description, as we did the
shed, the workbench would be described in full
as part of the description of any room that it’s
in. We only want to show a description when a
player LOOKs at the workbench, so our ‘instead of’ Perhaps most helpfully, you can The Inform IDE’s two panes
NZY^_]`N_TZY[]ZaTOP^L^[PNTʭN[S]L^PQZ]_SL_ keep your code in view while allow you to have your code
playing through your game. always visible while you
There’s also a toolbar button to use the second pane to
Inside containers
04 ‘Containers’ are objects that can contain
automatically replay your last
play-through, allowing you to
read the extensive built-in
documentation and code
other objects. Type: GLERKI]SYVGSHISRXLIǼ]ERH samples, display compilation
A biscuit tin is a closed container on the WIILS[MXEǺIGXWXLMRKWEQSRK errors, and manage settings
other automated testing features and extensions
workbench. The biscuit tin is openable. The
biscuit tin contains a pin.
When you test that code by running the game,
you’ll be able to OPEN the biscuit tin and TAKE the
Create an exit
pin. Now, on a separate line in the editor, type:
A red balloon is here. ‘A red balloon is
06 The player needs somewhere to escape to
ʮZL_TYR L]Z`YOɪ and a locked door to prevent them leaving. Type:
We’ve given the balloon a description, which, The Garden is a room.
unlike the workbench, will be displayed as part of It’s best to organise rooms and their objects
the description of any room that it’s in. together, so we’ve put the Garden below
everything to do with the Shed. Above it, type:
The shed door is a door. Instead of examining
_SPOZZ]^Ldɩ,^N]`ʬdOZZ]ɪ?SP^SPOOZZ]T^
Extending Inform’s verbs
05 We’ve got a pin and a balloon, but Inform
east of the Shed and west of the Garden. The shed
door is locked. The small brass key unlocks the
doesn’t know about popping. Let’s change that. shed door.
Towards the top of our code, we’ve created a
comment – text between square brackets – that
reads [specify new command: pop]. Below that,
Winning the game
we’ve used an ‘understand’ statement to describe
how our new verb works, and called the ‘check’
07 The player wins when they escape into the
and ‘carry out’ rulebooks (magpi.cc/informverb) RL]OPY,__SPaP]d_Z[ZQZ`]NZOPbPɪaP^[PNTʭPO
to make our ‘pop’ verb interact correctly with
poppable items.
a rule that runs every turn to see if they’re there:
Every turn:
Top Tip
Returning to our red balloon’s code, we can If the player is in the Garden:
Rule of law
now make it poppable and put something inside PYO_SP^_Z]dʭYLWWd^LdTYR
it. Type: ‘You’re free! You have at last escaped The Shed Inform 7’s syntax
A small brass key is in the red balloon. ‘A small of Mystery!’ ĜŸÚåĀĹåÚÆƼ
and very shiny brass key.’ Download our extended Shed of Mystery code ůųƚĬåÆŅŅĩŸű
Instead of popping the balloon with the pin: say (magpi.cc/shedofmystery) for two more keys to ŸƚÏʱŸůÏĘåÏĩű
±ĹÚůϱųųƼŅƚƋűţ
‘The balloon explodes with a loud POP, showering ʭYOPc_]LN_LYO`^PL^bPWWL^XZ]PT_PX^LYO
See magpi.cc/
you in bits of shredded rubber. A small brass key descriptions. Play with your own shed and see informverb2
O]Z[^Z`_ZY_Z_SPʮZZ]bT_SL^XLWW[TYRTYR what extra escape room challenges you’d like for details.
sound.’; move the small brass key to the Shed. to add.

Build a classic text adventure in Inform magpi.cc 45


TUTORIAL

Top Tip shed-of-mystery-mini.txt DOWNLOAD


THE FULL CODE:
[magic
brackets] > Language: Inform 7 magpi.cc/shedofmystery
Square brackets
are variously used 001. "Shed of Mystery Mini" by "Mighty Owlbear"
in Inform 7 to 002.
ÚåĀĹå±ÏŅĵĵåĹƋØ 003. [check for our win condition]
style text, or as 004. Every turn:
text replacements
005. If the player is in the Garden:
in text strings
006. end the story finally saying "You're free! You have at last escaped
or rules.
The Shed of Mystery!"
007.
008. [specify a new command]
009. Understand "pop [something] with [something preferably held]" as popping it with.
010. Understand "use [something preferably held] to pop/destroy/burst [thing]" as popping it
with (with nouns reversed).
011. Popping it with is an action applying to one visible thing and one carried thing.
012.
013. Check popping:
014. if the noun is not a balloon, say "You can't pop that."
015.
016. Carry out popping:
017. remove the balloon from play
018.
019. [Create a room and its contents]
020. The Shed is a room. "A cluttered wooden shed, lined with shelves and smelling faintly
of creosote."
021.
022. A workbench is here. The workbench is a supporter. Instead of examining the workbench,
say "The old workbench is almost, but not entirely, free of mess."
023.
024. A biscuit tin is a closed container on the workbench. The biscuit tin is openable. The
biscuit tin contains a pin.
025.
026. A red balloon is here. "A red balloon is floating around."
027. A small brass key is in the red balloon. "A small and very shiny brass key."
028. Instead of popping the balloon with the pin: say " The balloon explodes with a loud
POP, showering you in bits of shredded rubber. A small brass key drops out onto the
floor with a small pinging sound."; move the small brass key to the Shed.
029.
030. The shed door is a door. Instead of examining the door, say "A scruffy door." The shed
door is east of the Shed and west of the Garden. The shed door is locked. The small
brass key unlocks the shed door.
031.
032. [Another room. Freedom! ]
033. The Garden is a room. "A lush and slightly overgrown garden is bursting with life on
this bright, late Spring day. A gentle breeze rustles the leaves of trees populated by
a chorus of birds, and many-coloured insects flit amongst the flowers."

46 magpi.cc Build a classic text adventure in Inform


A R CA T R U ST E D O S

A tr ust computing base to protect your


containerized AI/ML and your data at the edge

TRUSTED ENVIRONMENT

TEST IT FOR FREE


OR VISIT
W W W .C
C Y S E C .C
COM

&<6(&LVDQ(XURSHDQGDWDVHFXULW\FRPSDQ\IRFXVHGRQGDWDSURWHFWLRQLQK\EULGDQGGLVWULEXWHGDUFKLWHFWXUHV
TUTORIAL

Build a Pico Keypad


Part 05

Mole Bop game


Create a game of Mole Bop using a 16-button, light-up keypad
connected to a Raspberry Pi Pico using a port expander

U
nderstand a way to expand your electronic uses one port for each row and column and scan
circuits using I2C. Learn about how to across them. An example matrix keypad is shown
Stewart interface with a port expander and see how in Figure 3. A switch matrix can have a problem
MAKER

Watkiss this can be used for a large number of switches with ghosting when multiple buttons are pressed.
`^TYRL^bT_NSL]]Ld?SPʭ]^_NT]N`T_T^ML^PO Sometimes it’s easier to use a port expander which
Also known as around an integrated circuit that you can build on increases the number of GPIO ports.
Penguin Tutor. a breadboard. Then, see how a similar technique
Maker and YouTuber
that loves all things is used for a 16-button, light-up keypad. Use the
Raspberry Pi and keypad to create a fun game of Mole Bop.
Pico. Author of Using I2C
Learn Electronics 02 I2C is an abbreviation for Inter-Integrated
with Raspberry Pi.
Circuit, which is a protocol for communicating
penguintutor.com
Using a port expanders
@stewartwatkiss 01 Raspberry Pi Pico has 26 general-purpose
between microcontrollers and integrated circuits.
It is a bus technology which allows multiple
input/output pins. For many projects that is more devices to be connected using only two wires;
than enough, but sometimes we need more. For a one for the data and the other for a clock to
16-way keypad using a port for each switch and synchronise the devices. Each device has an
one for each LED, we would need 32 ports. address which is used to determine which device to
?SP]PL]POTʬP]PY_bLd^_Z]PO`NP_SPY`XMP] talk to. An example is shown in Figure 2.
of ports needed. To reduce the number of pins for When using I2C, there needs to be pull-up
a keypad, you could use a switch matrix which resistors on the data and clock wires. These can
use the internal pull-up resistors available within
your Pico; if using devices over a greater distance,
external pull-up resistors may be required.

You’ll Need Using a MCP23008 port expander


03 The MCP23008 is an 8-bit port expander
> 2 × button switches which uses I2C to communicate with a Pico or
magpi.cc/sanwa other microcontroller. There are similar devices,
> MCP23008 port such as the MCP23017, which have more ports,
expander but using the smaller MCP23008 means that you
magpi.cc/
can create a circuit on a single breadboard. The
MCP23008
example circuit has just two buttons used as a
> Pico RGB demonstration. This is shown in Figure 1.
Keypad Base
?SPLOO]P^^T^NZYʭR`]LMWP`^TYR[TY^LYO
magpi.cc/ Figure 1 The MPC20008 is a port expander which can be
picokeypad 5 on the IC. Connecting all those pins to ground
used on a breadboard as a demonstration of how a port
expander can be used gives an address of 0x20 (hexadecimal value). The

48 magpi.cc Build a Pico Keypad Mole Bop game


TUTORIAL

Underneath the PCB is an


I2C port expander which
connects to each of the keys

The Pico RGB keypad has


16 silicon keys, each with an
addressable RGB LED

two wires between the MCP23008 and a Pico are


the I2C clock and data signals.

Communicating with
04 the port expander
You can use MicroPython to access all the extra
ports, almost as easily as if they are local pins.
To communicate between a Pico and the port
Pc[LYOP]dZ`ʭ]^_YPPO_ZOZbYWZLO_SPWTM]L]d
from magpi.cc/crankshawnzmp.
After uploading the library to your Pico, you
need to create an instance of I2C and use that that it is used as an input (0 would be used Figure 2 I2C is a bus
protocol allowing
to create an instance of the MCP23008 library. for output). multiple devices to
?SPQZWWZbTYR`^P^[TY^LYO ZYdZ`];TNZLYO be connected using
two GPIO ports on
address 0x20 on the port expander: mcp.setPinDir(0,1) Raspberry Pi Pico

from machine import Pin, I2C You can also enable pull-ups for the buttons
import mcp23008 using setPullupOn.
i2c = I2C(0, scl=Pin(5), sda=Pin(4))
mcp = mcp23008.MCP23008(i2c, 0x20) mcp.setPullupOn(0)

:YNPT_T^NZYʭR`]POdZ`NLY\`P]d_SP^_L_`^
using readPin.
Reading the inputs
05 ?SP[TY^NLYMPNZYʭR`]POL^TY[`_^ mcp.readPin(0)
using the setPinDir command. This takes
_SP [Z]_ Y`XMP]L^_SPʭ]^_L]R`XPY_LYO This gives a 1 when the button is pressed,
the value 1 for the second argument to indicate otherwise a 0.

Build a Pico Keypad Mole Bop game magpi.cc 49


TUTORIAL

Pico RGB keypad base Reading the keypad


Top Tip 06 Using a port expander, you could connect
08 The keypad is read by using the
that to buttons and LEDs to create a keypad. get_num_pads method. This returns a value
Other I2C Alternatively, you could buy a Pico RGB keypad between 0 and 65535 depending upon which
devices base which has already wired a keypad on a buttons are pressed. There are 16 keys, but
N`^_ZX;.-bT_SLŸ^TWTNZYPVPd[LO?SP bPɪaPZYWd`^PO_SPʭ]^_PTRS__Z^TX[WTQd_SP
There are many keypad uses a TCA9555 port expander on the PCB explanation. Figure 5 shows an overview of how
other devices
(Figure 4). This is like the MCP23008, but has 16 the binary number system works in relation to the
which use
I2C, including input/output ports and is a surface-mount package keypad numbers.
various sensors (better for PCBs, but not so good for breadboards). Inside the microcontroller, the status of the keys
and output The chip even uses the same I2C address of 0x20. is represented by a binary digit for each key. If the
devices such as The PCB also includes an APA102 addressable LED key is pressed, then it has a value of 1 and, if it is
X%ƤŸÏųååĹŸţ for each key. These are like NeoPixels, but use a not pressed, then it has a value of 0. The rightmost
protocol based on SPI instead of the single data digit is key 0 which, if pressed, has a decimal value
connection that NeoPixels use. 1. If button 1 is pressed, that has a value of 2. That
goes up to 128 if button 7 is pressed.

Preparing the keypad base


07 Shifting the values
The base needs a little assembly for the
buttons, then you plug a Pico using header pins.
09 To determine which button is pressed, you
Instead of installing the drivers separately, can read each of the bits in turn and see which are
Pimoroni provides a version of MicroPython with set to 1.
all the drivers pre-installed. Download the Pico Starting at the right, look at the rightmost digit
ʭWPQ]ZXmagpi.cc/pimoronipicogit. Transfer the which is a 0, which means that button 0 is not
@1ʭWP_ZdZ`];TNZLQ_P][]P^^TYR_SP-::?>07 pressed. Shift the numbers to the right and the
button during startup. The keypad and LEDs can rightmost digit becomes a 1, which means that
Figure 3 An
alternative is to use be accessed by importing picokeypad and creating button 1 is pressed. In Python, the shift is done
a matrix keypad. an instance of that class. using >> (two greater-than characters) followed
These have the
buttons arranged in by the number of bits to shift.
a grid of rows and
import picokeypad To perform the comparison, the bitwise AND
columns, which
reduces the number keypad = picokeypad.PicoKeypad() function is performed. If you compare using ‘&
of pins needed
0x01’ that will ignore all but the rightmost bit.

Creating a game
10 To turn this into a game, a random button
is chosen which is then lit up. The player must try
and press that button before the timer runs out. If
the player presses the button before lit_duration
is passed, then they score a point. If they don’t,
then the button turns red and the player loses

Figure 5 An example of the binary code showing keypad


numbers 1 and 7 pressed. The numbers above the binary digits
are the decimal equivalent for each key

50 magpi.cc Build a Pico Keypad Mole Bop game


TUTORIAL

mole-bop.py DOWNLOAD
THE FULL CODE:
> Language: MicroPython magpi.cc/molebop
TCA9555 port
expander
001. import time
002. import random
003. import picokeypad
004.
005. keypad = picokeypad.PicoKeypad()
006. keypad.set_brightness(0.5)
007. NUM_KEYS = keypad.get_num_pads()
008.
009. lit_button = random.randint(0, NUM_KEYS - 1)
010. lit_time = time.ticks_ms()
011. lit_duration = 1000
012.
013. score = 0
014. lives = 3
Figure 4 The TCA9555 port expander is the small square
integrated circuit mounted on the rear of the keypad PCB
015.
016. def all_off():
017. for i in range (0, NUM_KEYS):
a life. After all lives are lost, the grid lights up 018. keypad.illuminate(i, 0,0,0)
R]PPY_Z^SZb_SPʭYLW^NZ]PbT_SPLNSM`__ZY 019.
representing four points. 020. while True:
021. # Check to see if the time has expired
022. now_time = time.ticks_ms()
023. if (time.ticks_diff (now_time, lit_time) > lit_duration):
024. # light it red for missed
Adding a challenge
11 To make the game more challenging,
025.
026.
keypad.illuminate(lit_button, 255, 0, 0)
keypad.update()
each time a point is scored, the time for the next 027. time.sleep (1)
button is reduced by 30 milliseconds. Whenever 028. lives -= 1
a life is lost, it is increased by 500 ms to give a 029. if (lives <=0):
030. break
reasonable chance to score more points. This
031. # make the next one a little easier by adding 400ms
makes it possible to get a reasonable score, with
032. lit_duration += 500
_SPOTʯN`W_dTYN]PL^TYRO`]TYR_SPRLXP 033. # choose new button
Raspberry Pi Pico does not have a real-time 034. lit_button = random.randint(0, NUM_KEYS - 1)
clock, so to work out the time that has elapsed, 035. lit_time = time.ticks_ms()
time.ticks_ms is used. This measures time in 036.
milliseconds. The method ticks_diff is used to test 037. # Turn LEDs off and the lit one on
038. all_off()
whether the lit_duration time has been exceeded.
039. keypad.illuminate(lit_button, 255, 255, 255)
040. keypad.update()
041.
042. # scan keys to see if the lit_button key is pressed
Further development
12
043. button_states = keypad.get_button_states()
The game has some areas for improvement. 044. for i in range (0, NUM_KEYS):
045. if i == lit_button and button_states & 0x01 > 0:
Firstly, it will only run once and then you need
046. score += 1
to restart it from Thonny. Another while loop can 047. lit_duration -= 30
be added to keep the game running, along with 048. lit_button = random.randint(0, NUM_KEYS - 1)
resetting the score and other variables. 049. lit_time = time.ticks_ms()
Whilst it is possible to get a range of scores, 050. button_states = button_states >> 1
many players will score around the same amount. 051.
052. print ("Score {}".format(score))
This is due to the way that the complexity
053. all_off()
increases linearly. An alternative is to increase the
054. if (score > 64):
OTʯN`W_d`^TYRWPaPW^TY^_PLO 055. score = 64
Another improvement would be to have multiple 056. for i in range (0, score / 4):
buttons light at the same time. See version two in 057. keypad.illuminate(i, 0, 255, 0)
the GitHub repository for an improved version of 058. keypad.update()
the game.

Build a Pico Keypad Mole Bop game magpi.cc 51


TUTORIAL

Camera Module:
Part 03

/QTGQPXKFGQ
ECRVWTG
Discover in-depth settings for capturing video
with Raspberry Pi Camera Module
David
MAKER

Plowman

W
e met libcamera-vid at the end of the --framerate parameter:
David is an engineer last month’s Camera Module tutorial
at Raspberry Pi with (magpi.cc/130), and found out how libcamera-vid --width 1280 --height 720
a special interest
to record a short video clip. Like libcamera- --framerate 50 -o 50fps.h264
in camera software
and algorithms, and still, libcamera-vid has many more options for
image processing controlling the resolution, frame rate, and other This will record a 720p video at 50 fps, so long as
hardware. aspects of the video that we capture, and we’ll the camera can deliver the frames that quickly
raspberrypi.com discover some of those in this tutorial. (otherwise you will get the maximum frame rate
that the camera can supply).

%JCPIKPIVJGXKFGQ
TGUQNWVKQPCPFHTCOGTCVG Video encoders
By default, libcamera-vid will capture videos CPFƓNGHQTOCVU
at a resolution of 640×480 pixels. But it’s easy Videos, just like still images, are normally
to change this with the --width and --height compressed before saving them to disk. In fact,
parameters (just like libcamera-still). For example, it’s even more important to compress video
if you want to capture a video that is 1920×1080 frames because, with hundreds or thousands of
[TcPW^VYZbYL^ɩQ`WW3/ɪTY^_PLO[WPL^P`^P% Q]LXP^_SPZ`_[`_ʭWPbTWWPc[WZOPTY^TeP
After compression, the video frames are written
libcamera-vid --width 1920 --height 1080 -o _ZLʭWPbT_SL^[PNTʭNɩNZY_LTYP]QZ]XL_ɪ
full_hd.h264 There’s a choice as to how to organise video
Q]LXP^TYLʭWPYZ_WPL^_MPNL`^P_SP]PNLYMP
You’ll Need This particular resolution of 1920×1080 pixels Z_SP]OL_Lɧ^`NSL^L`OTZɧTY_SPʭWP_ZZLYO
should be regarded as the largest resolution that _SPNZY_LTYP]QZ]XL_OPʭYP^PcLN_WdSZb[WLdMLNV
> Raspberry Pi can be captured in video, unless noted otherwise software can access and decode the information.
> Camera Module in the text below.
magpi.cc/ Because we’re talking about videos now, we H.264 Files
cameramodule NLYLW^ZL^VQZ]OTʬP]PY_Q]LXP]L_P^-dOPQL`W_ The default encoder used by libcamera-vid
> Raspberry Pi OS libcamera-vid will deliver 30 frames per second is the H.264 video encoder. There is special
Q[^BPNLYL^VQZ]LOTʬP]PY_Q]LXP]L_P`^TYR hardware to support this so it combines both

52 magpi.cc Camera Module: More on video capture


TUTORIAL

7EWTFIVV]5M4RS[WYTTSVXW
PMFGEQIVE[LMGLGETXYVIWZMHISYWMRK
XLI-ZMHISIRGSHIVF]HIJEYPX

:MHISǻPIWEVIGETXYVIH
EXEVIWSPYXMSRSJ
¡TM\IPW

good performance and good compression. Once libcamera-vid -b 9000000 --width 1920
compressed, the frames are written back to back --height 1080 -o good.h264
OT]PN_Wd_ZLʭWPbSTNSbPYZ]XLWWdOP^N]TMPL^
LYɩ3!ɪʭWPLYOMdNZYaPY_TZYZQ_PYOPYZ_PT_ The 1,000,000 bits per second (1 megabit per
bT_S_SPʭWPPc_PY^TZYɩS!ɪ ^PNZYOZ]8M^aTOPZɩMLOS!ɪZ[_TZY
4_ɪ^bZ]_SYZ_TYR_SL__SP^P3!ʭWP^L]PaP]d shows far more objectionable compression
simple; they’re not really true container formats. L]_PQLN_^_SLY_SP$8M^ɩRZZOɪaTOPZ
That is, you couldn’t mix audio data in with the
video, and the video frames do not even have
timing information associated with them. Support
QZ][WLdTYRMLNV^`NSʭWP^NLYMPWTXT_POLYO
There’s nothing to stop you from
even where it is supported, the software will have compressing one still image after
to guess a framerate for the video.
Popular media player software VLC used to another (very quickly)
^`[[Z]__SP3!ʭWPQZ]XL_M`_XZ]P]PNPY_Wd
no longer plays them correctly. For this reason,
we recommend other programs, such as FFplay. MJPEG files
We’ve already seen how to record a video with We’ve previously encountered the JPEG image
LOTʬP]PY_]P^ZW`_TZY&LYZ_SP]`^PQ`WZ[_TZYT^ encoder for compressing still images. There’s
the bitrate parameter (--bitrate or just -b). This nothing to stop you from compressing one still
NZY_]ZW^_SP^TePZQ_SPaTOPZʭWPN]PL_POLYO image after another (very quickly) and saving
therefore the amount of compression and the _SPXMLNV_ZMLNV_ZN]PL_PLaTOPZʭWP?SL_ɪ^
perceived quality. Compare the following: PcLN_WdbSL_LY85;02ʭWPT^
There are some drawbacks, however. The
libcamera-vid -b 1000000 --width 1920 85;02ʭWPQZ]XL_R]Pb`[Z]RLYTNLWWdLYO^Z
--height 1080 -o bad.h264 lacks some clear decisions on exactly how to
format the JPEGs within them. Often they work
…versus: well, but support can be a bit patchy.

Camera Module: More on video capture magpi.cc 53


:MHIS ǻPIW EVI
compressed to save
?ZN]PL_PLYO^LaPL^PNZYO85;02ʭWP Uncompressed video files
vital storage space use this: 8Z^_aTOPZNZX[]P^^TZYQZ]XL_^L]PɩWZ^^dɪ
meaning that the video you save will have some
libcamera-vid -t 20000 --codec mjpeg -o degree of quality loss compared to the original
test.mjpeg camera images. Therefore, it’s also possible to
save completely uncompressed video, with the
It is necessary to specify the --codec option to NLaPL__SL__SP^PʭWP^NLYMPNZXPPc_]PXPWd
RP_L[]Z[P]85;02ʭWPNSLYRTYR_SPʭWPYLXP large, and you would need to know exactly how
on its own is not enough. Using the same JPEG you intend to use them.
encoder as libcamera-still, it supports the same To capture an uncompressed video use the
JPEG quality parameter (--quality or -q), though --codec yuv420 option as follows:
TYaTOPZʭWP^bPNLYYZ]XLWWdRP_MdbT_SWZbP]
values - indeed the default is only 50. An MJPEG libcamera-vid --width 320 --height 240
ʭWPbTWWTRYZ]PLYd^P__TYRXLOPMd--bitrate --codec yuv420 -o test.yuv420
(or -b).
DZ`NLY[WLdLY85;02ʭWPbT_Sʬ[WLd% ?SP]PWL_TaPWd^XLWW^TePSP]PŸ[TcPW^
XPLY^_SPʭWP^TePbZYɪ_Pc[WZOP_ZZ]L[TOWd
ffplay test.mjpeg and also that the system won’t get bogged down
trying to write vast amounts of data to the disk
85;02ʭWP^TYNZY_]L^__Z3!ʭWP^NLYMP (which can easily become quite slow).
recorded at resolutions greater than 1920×1080 Remember that, as usual, the --codec option is
pixels, though increasing the resolution will YPNP^^L]dLYO_SL_NSLYRTYR_SPʭWPYLXPZYT_^
decrease the framerate at which libcamera-vid ZbYT^TY^`ʯNTPY_
can keep up, resulting in dropped frames and 1TYLWWd_SPQZ]XL_ZQ_SPZ`_[`_ʭWPT^L^TX[WP
possibly choppy videos. dump of each of the uncompressed image frames,

54 magpi.cc Camera Module: More on video capture


TUTORIAL

ZYPLQ_P]_SPZ_SP]?SP^PL]PTYɩD@A[WLYL]ɪ online documentation for more information


format, which you will need to understand in (magpi.cc/cameradocs).
Z]OP]_ZXLVP`^PZQT_?SP`^PZQ_SP^PʭWP^
lies beyond the scope of this guide, and is not
recommended for beginners.
2CWUKPICPF
@YNZX[]P^^POaTOPZʭWP^LW^ZSLaPYZ TGUWOKPITGEQTFKPIU
]P^ZW`_TZYWTXT_L^3!ʭWP^OZ_SZ`RSWL]RP You can, of course, pause and resume a video
resolutions will very quickly become a bottleneck recording by stopping libcamera-vid (for example
due to the volume of data being written out. with CTRL+C) and restarting it again when you
want the recording to resume. But you may recall
how we could get libcamera-still to capture
The format of the output images when we press a key, and we can get

file is a simple dump of libcamera-vid to pause or resume a recording in


just the same way.
each of the uncompressed There are a few more options that we need
to cover:
image frames
• -t or --timeout The length of time, in
milliseconds, for which libcamera-vid will run.
MP4 files, audio and ?ST^XLdZQ_PYMPeP]ZTQdZ`ɪ]PRZTYR_Z[]P^^L
other container formats key to terminate the application.
BPɪaP^PPY_SL_3!LYO85;02aTOPZʭWP^L]P
YZ_bT_SZ`_NP]_LTYWTXT_L_TZY^?SPaTOPZʭWP • -k or --keypress Pressing the ENTER key
format with probably the best support is the MP4 toggles between recording and not recording.
ʭWPLYOWTMNLXP]LaTONLYN]PL_P_SP^POT]PN_Wd ?d[PɩcɪLYO[]P^^ENTER to quit.
even mixing in an audio stream if you have
a microphone. • --initial Followed by pause or record.
?ZN]PL_PLY8;ʭWPbPSLaP_ZNSZZ^PL This starts libcamera-vid in the paused (i.e.
OTʬP]PY_NZOPN4_bTWW^_TWW`^P=L^[MP]]d;Tɪ^ not recording) or recording state. Pressing
hardware H.264 encoder, but will access it via the ENTER key will then start or pause the
a third-party library that will take care of the recording, respectively.
MP4 container.
?Z]PNZ]OLY8;ʭWPbT_SZ`_L`OTZ`^P%

libcamera-vid --codec libav -o test.mp4

The usual options that we’ve seen so far


(--timeout, --width, --height, --bitrate) will
all work as before, though the other options
discussed later in this tutorial won’t (unless
stated otherwise).
?ZN]PL_PLY8;ʭWPbT_SLYL`OTZ
stream, use:

libcamera-vid --codec libav --libav-audio -o


test.mp4

This will make certain reasonable default choices


about the audio and how to encode it; please refer
to our online documentation for further details.
?SPɩWTMLaɪPYNZOP]NLYSLYOWPZ_SP]NZY_LTYP]
Raspberry Pi Camera
QZ]XL_^^`NSL^86AʭWP^Z]8;02?]LY^[Z]_ Module 3 features
a 12MP sensor,
Streams. It is possible to stream the latter
autofocus, and
directly over a network. Please refer to our -)7cWYTTSVX

Camera Module: More on video capture magpi.cc 55


TUTORIAL

Top Tip
• --split Every time a recording is resumed, the
]PNZ]OTYR^_L]_^b]T_TYRLYPbZ`_[`_ʭWP
1VJGTTGEQTFKPIQRVKQPU
libcamera-vid has many other parameters
Save space • --inline Tells libcamera-vid to insert certain LYObPɪWWWZZVaP]dM]TPʮd_S]Z`RSLQPbZQ
extra header information at the start of every them here.
After recording ʭWP_SL_T_b]T_P^DZ`^SZ`WOYZ]XLWWdTYNW`OP
ĀĹĜŸĘåŸØƋĘå this when using the --split option. Circular buffer output
ÏŅĵŞų域åÚĀĬåĜŸ
One useful feature is the ability to keep writing
Ÿ±ƴåÚƋŅÚĜŸĩţŽŸå
• -o or --output?SPYLXPZQ_SPZ`_[`_ʭWPZ] _SP]PNZ]OPOaTOPZ^_]PLX_ZLM`ʬP]TY=L^[MP]]d
ƋĘåĜųÏƚĬ±ųƚýåų
ŅŞƋĜŅĹƋŅŸ±ƴå± ʭWP^BSPYbPɪ]P`^TYR_SP--split option, we’ll ;Tɪ^XPXZ]d?ST^T^LWTXT_PO^TePLYObSPYT_
ŸŞåÏĜĀÏĹƚĵÆåų ZQ_PYbLY_PLNSZ`_[`_ʭWP_ZSLaPLOTʬP]PY_ ʭWW^`[_SPPL]WTP^_OL_LTY_SPM`ʬP]T^PaTN_PO_Z
ŅüŸåÏŅĹÚŸ YLXP^ZbPNLY`^P_SP^LXPɩNZ`Y_P]^dY_Lcɪ make space for the new frames. When libcamera-
üųŅĵƋĘååĹÚŅü that we saw with libcamera-still’s timelapse aTOPcT_^_ST^NT]N`WL]XPXZ]dM`ʬP]T^ʮ`^SPO
ƋĘåϱŞƋƚųåţ
option. For example, -o test_%03d.h264 to the disk. This enables you to leave the camera
bTWW b]T_P_SPZ`_[`_ʭWP^test_000.h264, ]`YYTYRTYOPʭYT_PWdM`__Z^LaPZYWd_SPWL^_
test_001.h264, test_002.h264 and so on. several seconds of data when some event occurs
that causes the program to be stopped.
Let’s try an example: Let’s see an example:

libcamera-vid -t 0 --inline --split libcamera-vid -t 0 --keypress --circular


--initial pause -k --width 1280 --height 720 8 --inline --width 1280 --height 720 -o
-o video_%03d.h264 circular.h264

This will start libcamera-vid in the paused ?ST^bTWW]`YTYOPʭYT_PWdb]T_TYR_ZLNT]N`WL]


state, so it won’t be recording anything yet. XPXZ]dM`ʬP]LYObSPY_SP`^P]_d[P^ɩcɪLYO
When ENTER is pressed, it will start recording ENTER, the program will quit after saving the last
video_000.h264. It will pause when ENTER #8-XPRLMd_P^ZQOL_L_Z_SPʭWPcircular.h264.
is pressed again, and then start recording ?SP^TePZQ_ST^XPXZ]dM`ʬP]T^OP_P]XTYPOMd
video_001.h264 when ENTER is pressed for the the number (which is in units of megabytes) after
_ST]O_TXP?ST^bTWWNL]]dZYTYOPʭYT_PWd`Y_TWɩcɪ the --circular option.
is typed followed by ENTER. You can use --signal instead of --keypress if
you prefer.
Recording in response to a signal
For those familiar with Linux signals, an
alternative to pressing a key is to send a signal For those familiar with Linux
instead. To do this, simply use -s or --signal
instead of -k (or --keypress).
signals, an alternative to
To send a record/pause signal to libcamera-
aTOʭ]^_^_L]_T_LYO_SPY_d[P_SPQZWWZbTYRTY_Z
pressing a key is to send a
another terminal window: signal instead
kill -SIGUSR1 `pidof libcamera-vid`
Timing Information
And you can force libcamera-vid to quit with: BP]PXL]VPOPL]WTP]SZb3!QZ]XL_ʭWP^
contain no timing information. libcamera-vid
kill -SIGUSR2 `pidof libcamera-vid` allows this information to be output to a separate
ʭWPQZ]WL_P]`^PZ]LYLWd^T^
This should be familiar as it matches libcamera- Here we simply specify the --save-pts option
still’s behaviour! QZWWZbPOMdLʭWPYLXPbSP]P_SPQ]LXP_TXP^

56 magpi.cc Camera Module: More on video capture


TUTORIAL

from the start of the video are stored in text form 4_ɪ^LW^Z[Z^^TMWP_Z_`]YZʬL`_ZQZN`^LYO^P_ When using
Camera Module 3,
in units of milliseconds. For example: the focus position of the lens manually. To do autofocus is enabled
automatically in
this, use the --lens-position parameter, and continuous mode
libcamera-vid --save-pts timestamps.txt -o [L^^ T_LaLW`PXPL^`]POTYɩOTZ[_]P^ɪXPLYTYR
circular.h264 the reciprocal of the focus distance. Thus, to
focus at a very close distance of about 0.1 m,
?SPʭWPtimestamps.txt will (for a 30 frames per pass in the value 10 (which is 1 / 0.1). To focus
second recording) start like this: L_ TYʭYT_d[L^^TYTYQZ]XLWWd_SPaLW`PZQ
TYʭYT_dDZ`NLY[L^^TYYZYTY_PRP]aLW`P^
# timecode format v2 too. For example:
0.000
33.332 libcamera-vid --lens-position 0.5 -o 2_
66.664 metres.h264
99.996
…will set the focus position to two metres and
…and so on. not move the lens again.

#WVQHQEWUCPF High dynamic range imaging


The Camera Module 3 supports high dynamic
JKIJF[PCOKETCPIG ]LYRP3/=TXLRTYR?Z`^PT_^[PNTQd_SP--hdr
Autofocus and high dynamic range imaging option on the command line, for example
are supported at the time of writing only on
Raspberry Pi Camera Module 3. The support libcamera-vid --hdr -o hdr.h264
mirrors that in libcamera-still very closely.
9Z_P_SL_YZY3/=NL[_`]P^NLYMP[P]QZ]XPOL_
Autofocus a maximum resolution of 4608×2592 pixels, but
When using Camera Module 3, autofocus is 3/=NL[_`]P^MPNL`^PZQ_SP^[PNTLWYL_`]PZQ
enabled automatically in continuous mode. This _SP^PY^Z]]P\`T]PO_Z^`[[Z]_3/=L]PWTXT_PO
means that the camera lens will move whenever to 2304×1296 pixels (exactly half the width and
necessary to maintain optimal focus on the centre SPTRS_ZQ_SPYZY3/=XZOP3!aTOPZʭWP^
part of the image, and this is probably what most are, in any case, limited to 1920×1080 pixels, so
users will want most of the time. this restriction is often not relevant.

Camera Module: More on video capture magpi.cc 57


TUTORIAL

Rad your ride with Pico


Turn a manual scooter into a motorised monster

S
cooters are fun, and can be a good hums into life, and the wheels of the scooter begin
alternative to cars and bikes when to turn. When the user wants to stop, they release
considering the daily commute. the throttle and apply a brake or use their foot to
They can even be useful while at work slow down.
if your job involves moving between A manual scooter works in a similar way, but
campus buildings several times a day, with more leg action and less throttle – surely we
Dr Andrew Lewis or travelling back and forth in large warehouses or just need to add a motor, some batteries, and a
hangars. Electric scooters are even more fun, but speed controller, and that’s everything, right? Well,
Dr Andrew Lewis is a they are also expensive. In this project, you’ll see it isn’t quite that simple. Firstly, manual scooters
specialist fabricator
and maker, and is the
how to take an ordinary manual scooter and make it come with very primitive brakes (if they have brakes
owner of the Andrew electric without resorting to expensive hub motors or at all). The wheels on the scooter are typically
Lewis°>orkshop conversion kits. This is a two-part project. In the first not designed to be driven, and just have a simple
part, we'll take a look at the components we'll use bearing and possibly a fork with a suspension
and how we'll need to modify our scooter to make it spring. Making a manual scooter move under
all work. In the second part of the project, you’ll see motor power means making some very permanent
how to power your motor from custom batteries. changes to the chassis of the scooter, mounting
The anatomy and function of an electric scooter the motor near to the rear wheel, enlarging the
isn’t mysterious or difficult to understand. The user rear fork to accommodate better brakes and a drive
stands on a platform, activates a throttle, a motor sprocket on the rear wheel, and modifying the

58 magpi.cc Rad your ride with Pico


TAKE
CARE
Scooters – whether
powered or not – carry
some risks. It's your
responsibility to make
sure the scooter
doesn't go faster than
wheel itself so that it can handle the extra stress you personally feel
coming from the motor.
OFF-ROAD comfortable with. You
are also responsible
Most of the issues with the wheel can be dealt
If you’re thinking of using an electric scooter in the UK, for ensuring that any
with by using some 3D-printed parts and a healthy you’re going to be disappointed to learn that you’re chassis modifications
dose of epoxy resin to reinforce the wheel. The not going to be able to ride it on the open road, or on a you make are sufficiently
drive sprocket for the motor and the disc to upgrade footpath, or even in a bike lane. Electric scooters are in strong. We strongly
the brakes can be mounted on opposite sides of a class of vehicle known as ‘powered transporters’. It’s recommend you err on
the rear wheel using 3D-printed parts, and using the same place you’ll find one-wheels, hovercrafts, and the side of caution as
electric skateboards. In UK law, a powered transporter your decisions on both


is the same as a motor vehicle, and as such you would these risks could impact
be expected to license and maintain it in exactly not just you, but the
Once you have a solid the same way as a car or motorbike. Unfortunately, people around you.
scooters don’t have some of the important features
wheel, you can build your needed to pass an MOT (Ministry of Transport) test
(like headlights, indicators, registration plates, etc.)
rear fork to match


– and so they will not be legal to ride on the road,
its width and you can’t get insurance to drive them. However,
they are still technically classed as motor vehicles,
so you aren’t allowed to ride them on the pavement QUICK TIP
either. If you do ride on the pavement or on the road, Cycle chains can be
plenty of resin to fill the space between the two you could be fined several hundred pounds and risk joined with a split
sides will make sure that the bolts have plenty losing your driving licence. You can ride them on link, so you don’t
of solid wheel material to make contact with private land – such as corporate campuses – with the have to buy a chain
landowner's permission. At the time this article was exactly the right
when the forces from the motor and brakes are
written, the government is developing new standards size. Simply remove
transferred through them. and adjustments that will eventually make electronic excess links, join the
Once you have a solid wheel, you can build your scooters road-legal in the UK. How long that process chain with the split
rear fork to match its width. If you have access to a will take depends on how quickly the government link, then tension
welder, you can do this very quickly by cutting the decides to move. the chain by moving
original rear fork into pieces and re-welding it with the motor.

Left
Most scooters don’t
really bother with
an effective brake,
because they don’t
go very fast and you
can stop them with
your foot. If you’re on
a motorised scooter,
you’ll need a more
powerful rear brake
to arrest your more
considerable forward
momentum. A disc
brake from a bicycle
will do the job. Just
remember that the
brake will only stop
the scooter, not you

Rad your ride with Pico magpi.cc 59


TUTORIAL

Right
Using a motor with a
sprocket and chain is
much cheaper than
using a hub motor and
allows you to increase
the torque from the
motor mechanically

MOTOR CONTROLLER


Most BTS7960 motor controllers are H-bridge
controllers that have a similar pinout. The boards have
two power inputs, one of which (often labelled as pins You will probably find that
B+ and B-) supplies power for the motor. Next to this
you won’t want to run your
input are the connections (M+ and M-) that directly
motor at 100% speed under


attach to the motor.
This tutorial is from The other power input is used to supply the logic side
HackSpace magazine. of the board, and is labelled as Vcc and GND. This logic any circumstances
Each issue includes a level power input runs at 3.3 V or 5 V and is isolated from
huge variety of maker the motor power connection for safety. With a Raspberry
projects inside and Pi Pico, you should be powering this with 3.3 V. The a larger gap. If you don’t have a welder, you can
outside of the sphere remaining connections on the board are used to control achieve similar results using threaded bar and
of Raspberry Pi, and the speed and direction of the motor, and optionally locking nuts with a spacer between each side
also has amazing monitor the current used by the motor. We won’t be
tutorials. Find out of the fork.
using the current-sensing features, so the pins labelled
more at hsmag.cc. For something like a light scooter, a 20 amp,
R_IS and L_IS can be ignored. The L_EN and R_EN pins
enable the motor to turn clockwise or anticlockwise 24 volt motor in combination with the gear reduction
when they are high, or disable the motor when low. from the sprocket drive should have plenty of power
Obviously, only one of these should be enabled at a time. to move an adult at terrifying speeds. By controlling
The LPWM and RPWM pins accept a PWM signal from the power to the motor using PWM signals from
QUICK TIP the Pico, or a solid logic high to power the motor at 100% a Raspberry Pi Pico, you can provide very smooth
power. Since a scooter generally doesn’t need a reverse
In MicroPython, the speed control without losing as much torque as
gear, you only need to connect either the left or right
Pi Pico PWM output you would if you simply reduced the overall supply
enable and PWM pins to the Pico, depending on which
ranges between 0 voltage. You will probably find that you won’t
way around your motor is connected. Assuming that
and 65025, so setting
you have a right-hand motor setup, you would make the want to run your motor at 100% speed under any
a PWM pin with
motor move by setting the R_EN pin HIGH and providing circumstances, and will throttle the maximum
pwm.duty_u16(32512)
a PWM signal to RPWM. PWM value to something less than bowel-voidingly
would give you about
50% power. high speeds.

60 magpi.cc Rad your ride with Pico


TUTORIAL

ANALOGUE IN
Setting the motor speed is only half of the process;
you also need to get a value from the user by reading
a throttle control. It’s tempting to think about creating
a simple throttle control using a potentiometer, but that
would be a bad idea. If you’ve ever used an old radio,
you’ll know that the potentiometer used in the volume
control gets worn out, and the volume of the radio
will suddenly change or crackle at full volume for a
fraction of a second. This is annoying in a radio, but if it
happens on a motor controller and the motor suddenly
speeds up to 100% without warning, the result could
be catastrophic. To avoid this problem, most electronic
throttle controls use a Hall probe and a magnet to
ensure smooth speed changes. The Hall probe and
magnet aren’t in physical contact and there are no
tracks to get worn, dirty, or broken. The probe normally
has two power pins and a signal pin, which outputs an
Above
analogue value to reflect the strength of the magnetic You will need to mount your motor so that the motor’s sprocket matches up with the sprocket
field it detects. As the magnet moves closer, the field on the wheel. The easiest way to do this is to Ä_ a mount for the motor on the rear of the fork
with slotted holes, and use the adjustment that the slots provide to position the motor correctly.
gets stronger. Checking the position of the throttle You can also use this technique to tension the chain between the motor and the wheel
controller is as simple as connecting up and polling the
analogue pin of a microcontroller, just as you would
with a potentiometer.
Left
You can see here
how much wider the
wheel becomes once
you allow for the
sprocket and brake
disc. Widening that
rear fork might seem
a bit daunting, but
it’s actually pretty
easy to do. Getting
rid of the in-built
suspension makes
things much easier
if you’re struggling,
and it won’t actually
make that much
difference to the feel
of the scooter

Above
To control a large motor, you will need to use a
powerful motor controller like the BTS7960, which
is often found on motor control modules that can
handle around 43 amps, when appropriately cooled

Rad your ride with Pico magpi.cc 61


TUTORIAL

Interactive
stream lights
Have your viewers change your lighting during streams with this
Raspberry Pi Pico-powered setup for major streaming services

Rob Zwetsloot
I
nteractive lights are hardly a new thing for as well as providing a ground for the circuit. Data
MAKER

streamers. If you have certain smart lights, is sent via a single pin which tells each LED how
Rob knows a you can connect them to Lumia Stream to act.
hedgehog that (lumiastream.com) and go from there. Of course, For larger lengths of NeoPixels, a 220 Ohm
streams model
kit building, that’s not as fun as making it yourself, and with a resistor between the 5 V pin and the NeoPixel
which needs Raspberry Pi Pico W and some NeoPixels, you can strip is best practice to stop any of the LEDs
decent lighting get one set up pretty quickly. from overheating.
for viewers to see
We’ve borrowed some code and ideas from Make sure your Pico is in range of a micro USB
what Gundams are
being made. Sean O’Steen’s excellent Raspberry Pi Pico Beret cable plugged into a PC so you can program it too.
(magpi.cc/picoberet) which has a web server and
magpi.cc
LYTXL_TZYNZY_]ZWWP]]`YYTYRZYOTʬP]PY_NZ]P^
on Pico. Now, let there be light.
Getting the code
03 We’ve uploaded the code for this to
Z`]2T_3`MLYOdZ`NLYʭYOT_L_%magpi.cc/
Ready your LEDs
01 For this use case, we just need to
streamlights. It comes in two parts – stream_
lights.py and secrets.py. You’ll need to modify
illuminate the area of a cutting mat – a relatively MZ_SQZ]dZ`]^[PNTʭN^P_`[&secrets.py just need
very small area compared to a room. As well as to have your wireless network info added, while
SPW[TYRbT_SaTOPZ\`LWT_d_SPMPYPʭ_ZQ_SP^P stream_lights.py code will need to be updated
lights is that it will also help the streamer see with your number of LEDs on line 15, NUM_LEDs.
what they’re doing. You don’t want to blind
yourselves with the LEDs!
We have a small strip of eight NeoPixels that
You’ll Need Code explained
bPɪaPN`_ZʬL]PPWbSTNSbTWW[]ZaTOP[WPY_dZQ
light to the desk when positioned in the correct
04 The reason a Pico W is needed for this
> Raspberry Pi
Pico W spot (see Step 7). project is that we’re making use of its web server
magpi.cc/picow capabilities. The idea is that once booted, Pico W
will run the code and set up the web server that
> NeoPixel LEDs
magpi.cc/ can be accessed via your local network. Sending
Wire it up
neopixels
> Stream bot, such as
02 Refer to Figure 1’s Fritzing diagram on how
web requests in the form of URLs is captured by
_SP^P]aP]LYObSPYL^[PNTʭN]P\`P^_T^[]ZNP^^PO
Mix It Up to wire up the NeoPixel strip to Raspberry Pi Pico T_bTWWLN_TaL_PLOTʬP]PY_WTRS_^P\`PYNP
mixitupapp.com W. It’s fairly simply though – Pico can provide Both parts of this code run on their own threads
power straight to the NeoPixel using the 5 V pin, so they’re able to work independently of each

62 magpi.cc Interactive stream lights


TUTORIAL

Attach NeoPixels to
wherever makes sense
for your streaming set up

Cameras need light and


so does the streamer
for model building

other – RP2040 has two cores making this much to Pico as well. Restart Pico and it will give you
easier to do. the IP address in Thonny you’ll need to send
The light sequences are done in a traditional web requests.
NeoPixel manner of setting the LEDs with simple
RGB values.

Test it out
06 Testing at every step is very important. So,
Set up Pico
05 Get Thonny on your PC, or boot up your
before we go any further, turn your Pico on and
wait for the lights to turn on. Once that’s done,
nearest Raspberry Pi. Hold down the BOOTSEL open a browser on your computer on the same
button, and connect Pico to your computer via local network, and enter the IP address from the
[]PaTZ`^^_P[LWZYRbT_S_SP@=7QZ]L^[PNTʭN

Testing at every step is


light command. For purple in this example, you’ll
YPPO_Z`^P^ZXP_STYRWTVP%$!#*[`][WP Top Tip
Check out some of the other links to make sure
very important they work as planned, or debug them if needed. Bright white?
We’ve used white
as the colour for
a USB cable. Once that set up is complete, open the lights in the
Secure your LEDs
Thonny, and click the Python version on the
bottom-right of the window. There you’ll get the
07 For this use case, we’re using a boom arm
code example.
However, that
option to install MicroPython to Pico, and in the attached to a desk to hold a smartphone to use might not be
the right tone
QZWWZbTYRbTYOZbdZ`ɪWWYPPO_Z^PWPN_ʭ]XbL]P as a camera. With the arm going over the area
for your stream.
for Pico W/WH. we’re capturing, we’ve attached the LED strip to
Try a warmer
Once that’s done you’ll need to save the the underside of the arm with some cable ties and orange for a more
stream_lights.pyʭWP_Z;TNZQ]ZX?SZYYdLYO _SPdWTRS_`[_SPL]PLU`^_ʭYPDZ`NZ`WOPL^TWd relaxing look.
rename it as main.py. Save the secrets.pyʭWP design and 3D-print your own stand, and we do

Interactive stream lights magpi.cc 63


TUTORIAL

Action groups
09 Creating a command on Mix It Up can be
done directly on the trigger (such as a new Twitch
subscriber) or you can create a universal command
_ZMPNLWWPOQZ]LYd_]TRRP]0T_SP]bLd_SPʮZb
of the command is the same, and it’s quite simple
here.
Go to the menu in the top-left and select
Action Groups. Click ‘New Action Group’ to open
the command editor. From the Action list on
the bottom of the window, select Web Request
and press the add button. Enter the URL for the
^[PNTʭNWTRS_LYTXL_TZYdZ`bLY__Z`^PPR
$!#[`][WPLYO_SPYNWTNV^LaP1]ZX
here you can test the command using the play
button when Pico is running. We suggest toggling
Figure 1: Pin 40 (top- recommend getting some frosted acrylic to cover the Unlock Command option as well, which will
right) is the 5 v pin,
while every square the LEDs so that the light on the desk area isn’t allow other commands to run if an issue occurs
pin on Pico is ground too sharp. with this one.
Make sure a power supply can reach your Pico
as well.

Top Tip Text commands


10 There are two major ways for a chat to
Lotsa lights Set up Mix It Up
08 Mix It Up is a customisable stream bot that
control your lights – one of the simpler ways is
by using chat commands. From the menu, go to
This example uses
allows you to create event triggers for a stream –
a small strip – for
larger setups, e.g., when a new person follows you, a video can
look into using be played on stream via an overlay in the broadcast Make sure a power
external power for software. Head to mixitupapp.com and download
the NeoPixels. the installer to your streaming PC, install it, and supply can reach your
connect to your streaming account (in our case,
Twitch), and go through the intro screens. Pico as well
Mix It Up is also a good companion to the
custom stream deck we made in magpi.cc/111, as it
is able to capture global hot keys sent by Keybow Commands and then to the Custom Commands
Using Action Groups 2040 more consistently than some other pieces of tab. We’ve made the chat trigger purplelight so
means you don’t
software, and can manually activate the desired that when someone in chat writes !purplelight
have to write out the
web URL every time function. (with the bang at the start) it gets activated.
From the Actions menu, choose Command,
change the Command Type to Action Group, and
select the appropriate action. From here, you can
also add multiple actions, with pauses in-between,
allowing you to change the light sequence without
changing the code on Pico.

Twitch redeems
11 4QdZ`ɪ]PL?bT_NSLʯWTL_PZ][L]_YP]
your viewers can collect channel points simply by
watching your streams. These points can then be
spent on redeems and are popularly used to play
a sound or get the streamer to drink some water

64 magpi.cc Interactive stream lights


TUTORIAL

DOWNLOAD
THE FULL CODE:
magpi.cc/streamlights

Remember to use
Happy streaming the IP address of your
or stretch. Mix It Up is able to read the list of
redeems and use them as triggers.
12 Make sure to thoroughly test the actions
Pico W for the
web requests

Go to the Twitch Dashboard, Viewer Rewards, before hitting live, and make sure to let your
and then Rewards and create a custom reward. chat know about the new functionality of your
Give it a name, a channel point cost, and ^_]PLX BSP_SP]T_ɪ^^SZbTYRZʬL2`YOLXZ]
consider giving it a cool-down so it can’t be used your wonderful visage, you may need to tweak
continuously too. Once it’s set up go to Twitch the code to get everything looking just right.
Channel Points in Mix It Up, Add Command to =2-NZOP^QZ]OTʬP]PY_NZWZ`]^NLYMP\`TNVWd
Existing Reward, and add the action group, like in Google’d and Pico’s code can be updated on the Create a Custom Reward on
step 10. ʮd_ZZ2731  your Twitch Dashboard

Select the correct variant, as we require


the wireless capabilities of Pico W

Interactive stream lights magpi.cc 65


FEATURE

Get photos – and video! - of your local critters.


By indoorsman Rob Zwetsloot

R
aspberry Pi Camera Modules are
wonderful things, and we’ve used
them for countless projects in the
pages of The MagPi over the years. You’re
coding them directly, so they’re incredibly
customisable, even being able to talk to the
web or the multitude of sensors available for
Raspberry Pi.
With all this power and a little bit of
bPL_SP][]ZZʭYRT_ɪ^TYN]POTMWdPL^d_Z`^PL
=L^[MP]]d;T_Z_LVPLWZZVZ`_^TOPLYOʭYO
out about the natural world around you. Here
are some projects to get you started…

66 magpi.cc Raspberry Pi Camera Traps


FEATURE

Urchin’s Ga
llery The finest ph
otos of the fi
nest wildlife
taken by the
finest microc
omputer

R
ob unabashedly loves hedgehogs
thanks to a blue one with attitude,
and as it’s his feature, he’s decided
to have a page dedicated to these ancient, Photo by
spiky, and cute garden dwellers. The Jolly Geographer
and Wildlife Trust BCN

Photo by
Keith Freeman
(@BiscuitKeith)

“Here’s a front and


back of Nora the
hedgehog, taken with
a My Naturewatch
Raspberry Pi camera”

“The hogs at the cat


feeder, I 3D -printed
some steps that they
sometimes use”

“Latest Hog Alley


music video. More
can be found @
hogcamb (mostly on
Photo by @adeibiza Instagram). Not sure
this kept me sane
during lockdown but
certainly busy.”

Raspberry Pi Camera Traps magpi.cc 67


FEATURE

Photo trap
projects
Build your o
wn, cheap n
ature camer
By Rob Zwet a
sloot
a p
e r r y P i C a m er a T r
a sp b
Sim p le R implecamtrap
magpi. cc/s

H
oused in a Tupperware box as
bPL_SP][]ZZʭYR_ST^[]ZUPN_XLVP^
use of an infrared camera with IR
LEDs to light up the night. Not only that, but
it teaches you how to set up MotionEyeOS to
sense movement and take photos and/or video
in the process – something you’ll be able to
N`^_ZXT^P_ZdZ`]ZbY^[PNTʭNL_TZY^TQdZ`
plan to tweak the build.
7TVP8d9L_`]PbL_NST_XLVP^`^PZQLY
LT]_TRS_QZZONZY_LTYP]LW_SZ`RSbPɪ]PYZ_
^Z^`]PLMZ`_SZbbPL_SP][]ZZQ_SPNLXP]L
Hot glue is
T^TY_SL_NZYʭR`]L_TZY4QdZ`SLaPLY4= actually an
NLXP]LM`_YZ_ZYPbT_S4=70/^dZ`NLY OK insulator
against the
LN_`LWWdRP_4=70/^L^TYOTaTO`LWNZX[ZYPY_^ weather
Q]ZXXZ^_ZYWTYPPWPN_]ZYTN^^_Z]P^ .XƶW HMǽGYPX XS
see because of
XLI GEQSYǼEKI

BIRDBOX
A project from the Raspberry Pi Foundation
(magpi.cc/birdbox), this camera trap
ƚŸåŸŸŅĵåÏŅĹÏåŞƋŸƼŅƚϱĹĀĹÚĜĹƋĘå
other projects here, but this one involves
constructing a birdbox too – a classic
beginner’s woodworking project.
Be careful to make sure any project like
this will not disturb the birds if they nest in
the box, though.

68 magpi.cc Raspberry Pi Camera Traps


FEATURE

My Na t
u
mynatur r ewa tch
I
t seems the popular way to make your
own wildlife camera is to house your ewatch.n
et
electronics in a watertight piece of
Tupperware and, apparently, use a large
plastic soda bottle as a sort of weather
shield for the lens of your camera. At least,
this is how the My Naturewatch team like to
build their cameras.
You can browse
?SPXLTY[L]_ZQ_SP[]ZNP^^T^M`TWOTYR the camera
with a phone or
the enclosure, as My Naturewatch has a
other device
[]PM`TW_>/NL]OTXLRP_SL_dZ`NLYWZLO
The solution is
ZY_Z=L^[MP]]d;TbSTNSbTWWLW^ZWP_dZ` very DIY, but
connect a phone, or other Wi-Fi enabled it works!

device, so that you can control it and also see


what it has taken.
4QdZ`ɪ]PWZZVTYR_ZM`TWOZYP;TXZ]ZYT
also sells a kit with all the electronics you’ll
need here: magpi.cc/mynaturekit.

ic PiCa m
F
ancy taking photos under the water?
An ta r ct /130 ?SP,Y_L]N_TN;T.LX[]ZUPN_ bP
c
magpi.c QPL_`]POTYT^^`Pmagpi.cc/130)
was created by a school student and
XLVP^`^PZQLaP]d^TX[WP[W`XMTYR^PLW
_TRS_PYPOMdLY`__ZN]PL_PLbL_P][]ZZQ
enclosure. With a clear acrylic plate on one
The hardware end, the camera can point outward and
is attached to
a wooden sled _LVPQZZ_LRP>ZQ_bL]PbT^PT_ɪ^LWT__WP
that slips into the
PVC piping
XZ]PN]`OPTYT_^Z]TRTYLWNZYʭR`]L_TZY
M`_Md`^TYR^ZXPZQ_SP_PNSYT\`P^TY8d
It was used in 9L_`]PbL_NS_SP>TX[WP.LXP]L?]L[^SZ`WO
Antarctic waters
to study ice algae allow you to make something a bit more
`^PQ`WQZ]YL_`]P[SZ_ZR]L[Sd

Raspberry Pi Camera Traps magpi.cc 69


FEATURE

Alert!
Power Tools
Be mindful of problems
caused by power tools.

Full kit
Be careful of vibration,
noise hazards and wear
protective clothing and
goggles.

magpi.cc/powertools

Cut to the
chase
with Natu
rebytes

Learn all about


il d l i f e Ca m
a tur e bytes W Astrophotography
N
ytes.org in The MagPi 128
natureb (magpi.cc/128)
37
£110 / $1

T
he Wildlife Cam from Naturebytes
is a Raspberry Pi A+-based device
that comes with a fantastic case
that holds Raspberry Pi, a Raspberry Pi
Camera Module, an IR lens to optimise
motion detection, and even an IP55
weatherproof rating. This means it can
[]Z_PN_LRLTY^_\`LY_T_TP^ZQO`^__SL_bZ`WO
LʬPN_Z[P]L_TZY^LYOLW^ZQ]ZXLbL_P]UP_
LW_SZ`RSSZ[PQ`WWddZ`bZ`WOYɪ_MP[ZTY_TYR
your pressure washer at it anyway.
DZ`bTWWYPPO_ZL^^PXMWPT_dZ`]^PWQ
3ZbPaP]T_U`^_]P\`T]P^^N]PbO]TaP]^LYO
the instructions are very comprehensive
bT_S[WPY_dZQ[SZ_Z^ɧLYO_SP]PL]P^ZXP
aTOPZR`TOP^_ZZ4YLOOT_TZYdZ`NLY^bT_NS
Z`_=L^[MP]]d;T,QZ]LEP]ZZ]8ZOPW-
QZ]XQLN_Z]L^bPWWL^Z_SP]VTYO^ZQNLXP]L
XZO`WP^TQdZ`]PLWWdbLY__Z`[R]LOP_SP
\`LWT_dZQ_SP[SZ_Z^
DZ`NLYLW^ZU`^_RP__SPNL^PZYT_^ZbY
QZ]SLWQ_SP[]TNPTQdZ`bLY__ZN`^_ZXT^PT_
Q`]_SP]?SPVT_SL^MPPYL]Z`YOQZ]XLYd
dPL]^YZbLYOT^L^_L[WP=L^[MP]]d;TVT_
The hardware is attached to a wooden
sled that slips into the PVC piping

70 magpi.cc Raspberry Pi Camera Traps


FEATURE

u td oo r
Other o
photog ra ph y
u see from yo ur garden?
W hat else can yo

Cheap All Sky Camera


magpi.cc/cheapskycam

J ULY IN
NATURE
U
^TYR^TX[WPbPL_SP][]ZZʭYR^`NS
as a plant pot and a dome, this
In the UK, July is the
simple build can help you track
ĀųŸƋüƚĬĬĵŅĹƋĘŅü
meteors in the sky using motion-sensing summer, so you’ll
code. 4_`^P^L#OPR]PPʭ^SPdPWPY^_Z see more creatures
NL[_`]PXZ]PZQ_SP^VdLYO_SP]P^`W_TYR and critters about.
[SZ_Z^SLaPTYNW`OPOXP_PZ]^ʮL^STYR Star trails are a
This includes bats,
across the sky and time-lapse star trails. great style of the common lizard,
astrophotography osprey chicks, stoats,
to try out
and many kinds of
ÆƚƋƋåųāƼţĘåÏĩŅƚƋ
discoverwildlife.com
for more info on the
Pla n t g rowth kind of things you
tim
magpi.cc/plantt el ap se can encounter in your
imelapse garden – and beyond!
- during the year.
(VIHMX &RH] 2SVǺI[

N
ot only does this project your water
plants when they’re needed, it
also keeps a time-lapse recording
of their growth. ?ST^^[PNTʭNaP]^TZYT^
The build does
used in a greenhouse but, with some expert require a car
XZOTʭNL_TZY^LYObPL_SP][]ZZʭYRT_NZ`WO battery, though

MP`^POTYLRL]OPYZ]PaPYQZ]TYOZZ][WLY_^
4_ɪ^LN_`LWWd\`T_PL^TX[WP^P_`[M`__SP
_TXPWL[^PMT_T^Pc_]LQ`Y

Raspberry Pi Camera Traps magpi.cc 71


REVIEW

PuppyPi
HiWonder hiwonder.com £445 / $559

State-of-the-art quadruped combines Raspberry Pi and ROS


for powerful learning options. By Lucy Hattersley

T
here’s no denying that PuppyPi is an eye- operating system), a motor control board, and
SPECS catching robot. Inside its black aluminium 7.4 V 2200 mAh LiPo battery. It’s a lot smaller
alloy frame this quadruped features eight than SpiderPi; it’s cuter too, even with the black
DIMENSIONS: high-quality HPS-0618SG coreless servo motors metal styling and single-eye camera. Inside the
226 × 149 ×
190 mm (length with metal joints, and a six-axis IMU sensor chip box are some coloured balls, tags, and an 8.4 V
× width × height), MPU6050 for robot posture detection. charger. We also got the PS2-style controller for
720 g, aluminium PuppyPi (magpi.cc/puppypi) is assembled by testing, and an Advanced kit comes with extra
alloy body HiWonder, who created the larger SpiderPi robot sensors and attachments. A pro model comes
COMPONENTS: (magpi.cc/119) and TonyPi (magpi.cc/111), all with Lidar.
Raspberry Pi strong contenders in the robotics space. Our test model worked fresh out of the box.
4 4GB, eight At the front of PuppyPi sits a 480 p camera and Power it up using the switch on the side, and
HPS-0618SG inside is a Raspberry Pi 4 running ROS (robot it instantly stands up and transmits a Wi-Fi
coreless servos,
Raspberry Pi
expansion board,
480P/8DOF
camera

CONTROL
METHODS:
iOS/Android
apps, PC
application,
Python API,
PuppyPi V1
software,
Lab tool, PS2
controller

The quadruped looks


stylish with its black
aluminium casing

72 magpi.cc PuppyPi
REVIEW

network to join. The


HiWonder iOS/Android
An excellent
app enables direct
control of PuppyPi from
addition to any
a smartphone. You robotics course
remotely control the
robot as the camera view or classroom
displays on your screen.
,]LYRPZQ[]POPʭYPO
actions are available: sit, beyond the iOS/Android
bow, shake hands, and app and dive into
so on. There are also the world of Python The Raspberry Pi
colour recognition, target programming and ROS accessory board
connects to the
colour tracking, QR code experimentation. To servo motors, and
provides GPIO and IIC
tag recognition, OpenCV this end, a huge range
connections
face detection, and line- of tutorial PDFs are for accessories
following modes. provided by HiWonder
You control the robot via Google Drive (magpi.
via the Android or iOS cc/puppypidocs). These
app, a desktop app, or
using the optional PS2-
cover everything from
Python, Gazebo, ROS and
Verdict
style controller. Next, OpenCV vision tracking; A fantastic
bPʮT[[PO_SP[]Z_PN_TaP up to stair climbing and quadruped that’s
WTOZʬ;`[[d;T_Z_LVP obstacle avoidance. easy to set up and
start using. Packed
a closer look inside. We didn’t encounter
with detailed
There is a Raspberry Pi 4 with 4GB RAM and a any real problems during testing. Both Raspberry
documentation
motor control and expansion board. This features Pi OS and the PuppyPi PC_Software app defaulted to explore every
a barrel jack for charging, four servo ports, two _Z.STYP^PPL^dPYZ`RS_ZʭcTY;]PQP]PYNP^ facet of dog-
GPIO ports, and four IIC ports, RGB lights, and PuppyPi is obviously not cheap in the world of themed robotics.

9
_bZ[]ZR]LXXLMWPM`__ZY^0c_PY^TZY^ZʬP]PO Raspberry Pi robotics, but Boston Dynamic’s
by HiWonder include a Lidar module, ultrasonic Spot robot comes in at roughly £200,000, so

/10
sensor, MP3 module, display, and touch sensor. it’s relative. We think this would be an excellent
The software running on PuppyPi is Raspberry addition to any robotics course or classroom.
Pi OS with custom
applications and ROS
(robot operating system)
support. Connecting to
Raspberry Pi via VNC
reveals a PuppyPi desktop
application that is used
to visually program
and chain together
commands. You can dig
deeper with a Python API,
and it supports Gazebo
simulation (gazebosim.
org), enabling you to
simulate movement
in advance.

Deep training
Once you’ve connected
PuppyPi to your network, The Raspberry Pi OS PuppyPi V1.0 app used to chain together commands
it’s possible to move

PuppyPi magpi.cc 73
REVIEW

u-maker Box
Weidmüller magpi.cc/umaker £21 / $27
SPECS

DIMENSIONS: Not sure what kind of case to get? Try out the case
120.4 mm ×
120.4 mm ×
35.5 mm
that can be just about anything. By Rob Zwetsloot
WEIGHT:

C
93.2 g hoosing a case for your Raspberry Pi can
be a little tricky when there are many
FASTENERS: competing products on the market. You
Magnetic
can always make one with LEGO, 3D-printed parts,
cardboard, etc. if you have the means, making the
choice even more complex.
The u-maker Box may not solve that issue, but
it is at the very least quite unique in its approach
to Raspberry Pi case design. You can plonk a
Raspberry Pi 4 inside it and be done if you want,
and with magnets fastening the whole thing and
plenty of space inside it, it’s not the worst case
you could use.
The standard box is very unassuming but
What’s cool, though, is that you can really makes for a good basic enclosure
modify and personalise the case to what you need
it to do thanks to a smart construction system and
freely available templates to play around with for
3D printing.

Snap build
Verdict The standard box comes with some mounts that
allow you to attach it to a wall or VESA mount, and
A unique and even a special one for boom arms. As well as the
very cool way extra bits in the Extension Kit that help connect
to customise or extra boards, brackets, or even a case fan, there’s a
prototype a case
_ZYZQ?STYRTaP]^PʭWP^QZ]aL]TZ`^VTYO^ZQ^_LYO^
for your Raspberry
Pi projects. Pc_PYOP]^LYOPaPYLYLW_P]YL_PWTO_SL_NLYʭ_L

10 10
square HyperPixel.
The number of options are truly astounding and

/
none of it looks or feels hacky. It’s just a very nice
The ridges on the corners are used smartly
to hold the case on various accessories implementation of the design idea.

74 magpi.cc u-maker Box


REVIEW

Inky Impression ¡


Pimoroni magpi.cc/impression7 £70 / $72
SPECS

DISPLAY:
7.3-inch e-ink, Ideal for showing artwork and data, this is The 800×480
widescreen display
800×480 pixels,
seven colours a super-size e-ink display. By Phil King can render dithered
colour images with a
fair amount of detail
FEATURES:

T
4 × user SP4YVd4X[]P^^TZY"ťT^LYPb^`[P]
buttons, ^TePaP]^TZYZQ;TXZ]ZYTɪ^Q`WWNZWZ`]
I2C and SPI PTYVP[L[P]3,?QZ]=L^[MP]]d;T. We
breakout pins,
booster header,
reviewed the original 5.7-inch model in issue 102
stand-offs (XLR[TNN); there’s also a 4-inch version.

DIMENSIONS:
170.2 × 111.2 mm The big draw here
is the size of the
screen, measuring 7.3
inches diagonally
The rear of the Inky Impression board also
features a set of breakout pins for power, ground,
The 7.3-inch display is considerably larger than I2C, and SPI to connect extra components such as
a full-size Raspberry Pi board, so is supplied with sensors – perhaps for a weather display.
an extra female header to boost its height, along
bT_S^ZXPXP_LW^_LYOZʬ^LYO^N]Pb^_Z^PN`]P Widescreen wonder
it. You need to take a little care when mounting it, Naturally, the big draw here is the size of
holding it by the sides rather than pushing down the screen, measuring 7.3 inches diagonally.
on the glass screen. A resolution of 800×480 equates to a pixel
density of 127.8 ppi – just marginally lower
_SLYZY_SP "ťXZOPW4Y[]LN_TNPTXLRP^WZZV
detailed and smooth enough from a 30 cm-plus

Verdict
viewing distance.
To display a custom image (JPG, PNG, etc.),
you can use Pimoroni’s handy dithering code to
A whopper of an process it for the seven-colour e-paper. A one-line
e-ink screen with
installer is used to download the Python library,
full colour and
plenty of room to fonts, and examples from the GitHub repo
display images (XLR[TNNTYVdRT_). Note that you need I2C
and/or data. enabled to detect the board.

8
The main downside, as with all colour e-ink
displays, is a slow refresh rate: around 40 seconds,

/10
depending on the complexity of the image
4RXLIVIEV]SYƶPPǻRHEFVIEOSYXLIEHIV
ERHWSQIGSSPWMPOWGVIIREVX[SVO being drawn.

76 magpiGG .RO].QTVIWWMSR
REVIEW

WuKong 2040
Elecfreaks magpi.cc/wukong2040 £8 / $10

Do just about everything with a Pico thanks to WuKong 2040.


By Rob Zwetsloot

O
The board is packed with features that
ne of the more popular type of make great use of Pico’s own functionality
SPECS Raspberry Pi Pico add-ons that
we hadn’t quite foreseen was the
SIZE: educational breakout board. Pop your
55.8 × 87.8 ×
Pico onto a board and start coding it to
36.3 mm, 50 g
(without Pico NZY_]ZWOTʬP]PY_NZX[ZYPY_^LYO]PLO
or battery) various sensors – it’s a great educational
tool for people of all ages, and usually
POWER: dirt-cheap too.
18650 lithium
battery At under £10, the WuKong 2040
certainly keeps prices low while still
60-minute
packing a huge array of features on a
battery life
small board. Buzzers, buttons, LEDs,
2.8 V ~ 4.2 V motor controllers, a traditional GPIO
INTERFACES: breakout to hook up more, and the ability
2 × buttons,
2 × LEDs, 1 × to power it all with a
buzzer, motor
interface, GPIO At under £10, the WuKong 2040 certainly rechargeable battery so you
can take it anywhere.
interface, I2C
interface keeps prices low while still packing a huge
Code by numbers
array of features on a small board Programming a Pico
attached to the board is
quite simple, making use
of standard MicroPython, CircuitPython, and C
libraries to work, and each pin and component
labelled with the corresponding GPIO to which it’s
Verdict connected. Examples are given in CircuitPython on
the website, which can be fairly easy to translate
Small, reasonably to MicroPython if needed, and give you a nice little
priced, and overview of what you can do with the board.
packed with
For those wanting a more practical application
functionality, this
board is a fun way of the board, it also comes with a little add-on
to learn and grow that makes the base compatible with many kind
with Pico. of brick building systems like LEGO – a good way

9
to create a fun robot
Some great examples completely powered
of how you can use the

/10
by custom code you
included base adapter for
brick-building systems made yourself.

WuKong 2040 magpi.cc 77


REVIEW

Badger 2040 W
(Pico W Aboard)
Pimoroni magpi.cc/badger2040w £27 / $28
SPECS
4RXLIVIEV]SYƶPPǻRH
DISPLAY: Pico W, a reset button,
2.9-inch e-ink, Much more than a badge, this versatile mini e-ink FEXXIV]GSRRIGXSVERH
Qwiic/STEMMA QT
296×128,
monochrome display has wireless connectivity. By Phil King port – to which you
GSYPHGSRRIGXEWIRWSV

T
FEATURES: he Badger 2040 W is a mini monochrome
Pico W, 5 × user
buttons, reset e-ink display with wireless connectivity.
button, LEDs, Unlike the original Badger 2040 (reviewed in
Qwiic/STEMMA issue 116, magpi.cc/116), this new model is based
QT port around a Pico W pre-soldered to the rear.
DIMENSIONS: Another improvement is the inclusion of a real-
85.6 × 48.7 × time clock (RTC), enabling it to keep time even
10 mm when in ‘super deep sleep’ mode, with Pico W
powered down – in which it draws a minuscule
Ũ, ZQ N`]]PY_
Talking of power, you will want a portable way
of supplying it. To this end, there’s a JST battery
connector on the rear. If you buy the accessory kit
version, you get – along with a lanyard – a 2×AA A real-time clock enables it
battery pack with a Velcro patch to stick it to the
rear of the board.
to keep time even when in
Alternatively, you could use a standard USB
power bank connected to Pico W. Both solutions
‘super deep sleep’ mode
are a little chunky, though, so you might prefer a
slimline LiPo battery pack. Easy to program
BSPY ʭ]^_ [ZbP]PO `[ _SP -LORP]  B
Verdict launches into ‘Badger OS’ with a scrollable menu
of icons to choose demo programs and tools.
An interactive These include a badge, digital clock, e-book
badge that reader, interactive checklist, news headlines, and
doubles as a
weather dashboard.
versatile mini
Naturally, you can connect Pico W to a computer
e-ink display with
a reasonably quick via USB to customise the examples or create new
refresh rate and programs – in MicroPython or C/C++. Pimoroni’s
Wi-Fi connectivity. standard PicoGraphics library makes it easy to add

8
bitmap images, and several fonts are supported.
You’ll need to add your Wi-Fi credentials to try

/10
out examples such as news and weather, as well as
8LI'EHKIV;ƶWQMRMQSRSGLVSQIIMRO
HMWTPE]MWWYVVSYRHIHF]XEGXMPIFYXXSRW setting the correct time via NTP.

Badger 2040 W (Pico W Aboard) magpi.cc 79


RESOURCES

10 Amazing:
Cases
FLIRC case
Media shelf ready
Designed for use by your TV, this range of cases doesn’t look out
Protect your Raspberry Pi with of place next to Blu-ray players or satellite boxes.

these excellent enclosures RFLUNHH‫ܫ‬NWH | £12

R
aspberry Pi is hardly fragile, but it really is
recommended to get some kind of case for your
microcomputer (or microcontroller), even if
you’re just cutting some holes in the cardboard box it
comes with. Here are ten great cases that are a little more Argon EON NAS
sturdy though.

File server
The price may be eye-watering, but
this enclosure allows you to add four
hard drives, includes an RTC, cooling
fan, programmable OLED display,
and room for your Raspberry Pi.

magpi.cc/argoneon | £144

Pibow
Layers of case
{ĜĵŅųŅĹĜűŸŅųĜčĜűĬā±čŸĘĜŞŞųŅÚƚÏƋĜŸƋĘĜŸŸƋƚųÚƼϱŸåĵ±ÚåƚŞ
of laser-cut acrylic layers. There are many styles and colours to
get as well.

magpi.cc/pibow | £6

SmartiPi Touch Pro


Case, stand, display
œĜƋʱĹŅþÏĜ±ĬƋŅƚÏĘŸÏųååűĹÚ±±ŸŞÆåųųƼ{ĜØƼŅƚϱĹÏųå±Ƌå
a quick interactive display that needs very little space and is
extremely customisable.

magpi.cc/smartipipro | £30

80 magpi.cc Cases
RESOURCES

4ǽGMEPGEWI
Simple and clean
‰ĘåŅþÏĜ±ĬϱŸåŸĹƚčĬƼĀƋŸ±±ŸŞÆåųųƼ{ĜĜĹŸĜÚåţ‰ĘåųåűŸ±
version of all types of Raspberry Pi, and even a case fan if you’re
using your Raspberry Pi at full power regularly.

magpi.cc/case | £6
SecurePi Case
Locked down
This case allows you to cover up IO ports on Raspberry Pi,
including the SD card slot, for increased security.

magpi.cc/securepi | £10

NESPi 4 case
Classic console body
Lots of people like to use a Raspberry Pi for retro gaming, so
what better way to display it than with it inside a retro console
case with a fake cartridge?

magpi.cc/nespi4 | £29

Zebra Pico case


PiBoy XRS Small layers
Due to the way Pico is used as a
Handheld alternative
microcontroller inside projects, you
We gave this case a 10/10 a few months ago in The MagPi as it’s rarely see cases for it. It still looks
pretty much the ultimate retro handheld machine. You can even great in one if you’re using it for
stream Steam games to it. prototyping though.

magpi.cc/piboyxrs | £120 / $150 magpi.cc/zebrapico | £7 / $9

Cases magpi.cc 81
RESOURCES

Learn Assembly
with Raspberry Pi
Get to grips with the obtuse technology
that underpins all modern computers

Programming
from the ground up
Robert G. Plantz Assembly language is the low- that all computers run. It can be
AUTHOR

level coding language used to MLʰTYRM`_WPL]YTYRZ]L_WPL^_ computer organization and


Price: control computers. attempting to learn Assembly) is how it relates to ARM Assembly
FREE
When you program in a a noble pursuit for all coders and language. With detailed sections
magpi.cc/introarm higher-level language, like C computer users. on programming, addressing
or Python, it is converted into This website, Introduction modes, data movement
Assembly so that the computer to Computer Organization: instructions, arithmetic,
can run it. ARM Assembly Language logic instructions, and more,
Assembly is nearly one-to- Using the Raspberry Pi, is a this guide ensures a strong
one with machine code, the resourceful guide to learning foundation for anyone keen on
series of instructions made up ARM Assembly. The online understanding the nuances of
of zeros and ones that make up book provides a comprehensive ARM Assembly language and
the data and logic commands learning path to understanding computer organization.

ARM Assembly courses


Learn ARM Assembly by ARM ASSEMBLY LANGUAGE
FROM GROUND UP language programming, focusing on
following a course online This Udemy course, by Israel Gbati, ARM Cortex-M microcontrollers.
is well-structured and covers magpi.cc/courseracortexm
the fundamentals and advanced
concepts of ARM Assembly language, ARMV8-M ARCHITECTURE
making it ideal for beginners and FUNDAMENTALS
intermediate learners. 8LMWGSYVWIJSGYWIWWTIGMǻGEPP]SR
magpi.cc/udemyarm the Armv8-M version of the Arm
Architecture, used in Raspberry Pi 4.
EMBEDDED SYSTEMS It’s another one created by ARM and
WITH ARM describes the instruction set and
This Coursera course, provided by architecture in detail.
ARM, dives deep into Assembly magpi.cc/courseraarmv8

82 magpi.cc Learn Assembly with Raspberry Pi


RESOURCES

Raspberry Pi Assembly ARM


Language Programming Assembly
videos
Stephen >_P[SPY>XT_ST^LSTRS[]ZʭWP the versatile Raspberry Pi
AUTHOR

Smith name in the world of ARM for practical, hands-on Understanding ARM
Assembly language, so much so learning experiences. by following these
Price: that we asked him to write us a Readers are guided through
£35/$35 YouTube courses
series of Assembly tutorials in the fundamentals of Assembly
magpi.cc/rpiassembly
The MagPi^_L]_TYRbT_ST^^`P language, and then onto more
116, magpi.cc/116). complex programming
His book, Raspberry Pi concepts. The
Assembly Language Programming, journey
is the one to get for anyone culminates
interested in delving into the in the
depths of Assembly language development
using Raspberry Pi. of a fully ASSEMBLY LANGUAGE
This book takes a focused functional TUTORIAL
approach to teaching Assembly bare metal Derek Banas is known for
language in an accessible operating his clear and thorough style,
and engaging way, utilizing system. making complex topics
accessible to beginners.
This video serves as a great
introduction to Assembly with

Raspberry Pi Assembly
Raspberry Pi.
magpi.cc/assemblytutYT

Language RISC OS Beginners ASSEMBLY LANGUAGE


PROGRAMMING WITH
Bruce Smith RISC OS is an alternative []ZR]LXXTYR^[PNTʭNLWWdQZ] ARM
AUTHOR

operating system originally the Raspberry Pi. This extensive video tutorial
Price: designed by Acorn computers The book starts with an from freeCodeCamp covers
£16/$16 and kept alive by volunteers. introduction to Raspberry Pi ARM Assembly language with
magpi.cc/ Bruce Smith uses RISC OS to and RISC OS, setting the stage ARMv7 from the basics to more
riscosassembly
provide a unique and insightful for a comprehensive exploration complex concepts.
guide to the fundamentals of Assembly language magpi.cc/freeCCARM
of Assembly language programming. Each chapter
building upon the last, covering
topics from basic concepts INTRODUCTION
to more advanced aspects of TO ASSEMBLY
Assembly language. PROGRAMMING WITH
The book’s focus on RISC OS ARM
[]ZaTOP^LOTʬP]PY_[P]^[PN_TaP This series of 16 tutorials by
on Raspberry Pi programming, OliveStem demonstrates ARM
which makes a lot more sense memory layout, arithmetic, and
when you are so deep in the logical operations.
world of ARM Assembly. While magpi.cc/OliveStemARM
RISC OS and ARM Assembly are
both niche subjects, they tag
team well together.

Learn Assembly with Raspberry Pi magpi.cc 83


INTERVIEW

Alistair
MacDonald
Maker and Maker Space founder, Alistair likes to
bring the joy of his hobby to the community

> Name Alistair MacDonald > Occupation FabLab manager


> Community role Event organiser > URL fablabsunderland.org

A
popular plot device for reputation and most of my work “Today I run FabLab
stories is simply ‘I’m came through word of mouth. Sunderland where we support
bored of my job and In the end, I specialised in both students and businesses
I am going to do something prototyping products, creating alike in creating almost
else’. It’s popular because it’s interactive displays, and anything,” Alistair says. “We
relatable, even if not everyone supporting artists in creating ZʬP]/[]TY_TYRWL^P]N`__TYR
is able to manage it. Alistair artworks on the side. It was electronics fabrication, CNC
MacDonald did though after random, and at times just crazy, routing, vinyl cutting, and
spending years developing “big and I liked that.” many, many other things.”
boring software.” He began to teach others his
“I needed a change, so I set skills at a local university, and What is your history
up on my own with the aim of this has expanded even further with making?
Trundlebot is an
educational MicroPython doing more fun and interesting to becoming a founding member I don’t have a memory of when
robot created by Alistair,
projects,” Alistair tells us. “This of the Newcastle hackspace I started making things. It’s
and it won Electromaker’s
PCB project design contest worked out, and I gained a called Maker Space. just what I have always done.
When I was young, my favourite
books were all making books.
That, and books on how things
worked. The earliest project I can
remember is Roby, a cardboard
robot with lights on the front.
?SP^PbP]P^bT_NSPOZYLYOZʬ
by moving paper clips that were
drawing-pinned to a piece of
wood. I must have been around
seven years old at the time. My
skills have moved on since then
but, if I am honest, my childlike
joy of such things has not.
As I got older, I would study
electronics catalogues and
datasheets and would want to
try everything. I would ask my
father to buy components and
make things like disco light
controllers, audio mixers, and
model railway control systems.

84 magpi.cc Alistair MacDonald


INTERVIEW

Some things worked, some community in Newcastle upon about what we were up to. FabLab Sunderland is a
great place to learn how to
things did not, but I learnt from Tyne, and a few big companies We talked at local tech user make, and also just make
all of them. wanted to check if their software groups and events at our local WXYǺ]SYVWIPJ

After I graduated [university], I would run in the [Raspberry] Pi. science centre. We rebranded
started doing a few small projects from Hackspace Newcastle to
again, but it was not until the How did Maker Space start? Maker Space (a unique and more
birth of the Arduino that I really A long, long time ago I wanted descriptive name back then).
got back into electronics. It was to create a space where we could We set up an online discussion
not until much later, when we make things. Or, to be more group about making to try to
created Maker Space, that I had ^[PNTʭN4bLY_PO_SP^[LNP bring people with that making
DNA in them together. In the
end we got more people involved
My good friend Brian and I decided to and, when you have more people
sharing the load, things become
form a hackspace easier. We owe a lot to those
bSZ[`__SPPʬZ]_TY_ZOLd

access to the facilities to do more and the only way it was going
physical builds again. to exist [was] if I created it.
Back then, I envisaged a kind
When did you learn about of workshop, an art studio, and
Raspberry Pi? community centre all wrapped
Very early on. I cannot into one. In the end, my good
remember exactly when I heard friend Brian and I decided
about it, but it was long before to form a hackspace, and we
they were publicly available. I managed to rent a small space at
_]TPO_ZRP_ZYPZQ_SPʭ]^_ML_NS the back of a community cinema
and managed to place an order, in the city.
but something went wrong with The problem was that, back
the order and the order was then, no one else was looking for
cancelled… I did still manage to something like this, or if they
get one early on though. I joke bP]P_SPY_SPdbP]PYZ_ʭYOTYR
that I gained a lot of friends us. In the end, we realised that
because of this, but a lot of we needed to change how we
people did borrow it. We have were reaching out to people.
They also get into the spirit of the
an active software development We did things like blogging maker season at FabLab Sunderland

Alistair MacDonald magpi.cc 85


THIS MONTH IN RASPBERRY PI

MagPi
01

Monday
Amazing projects direct from our Twitter!

E
very Monday we ask the question: have you
made something with a Raspberry Pi over
the weekend? Every Monday, our followers
send us amazing photos and videos of the things
they have made.
Here’s a selection of some of the awesome
things we got sent this month – and remember
to follow along at the hashtag #MagPiMonday!

01. A fancy piece of kit that seems great for


crop monitoring
02. Pi Wars is back in a big way
03. It’s very optimistic to have it be green
when it’s close by, even though
it’s 250 miles above ground
04. You too can get our books delivered
around the world from magpi.cc/store
05. &L[IRIIHEJI[9RǻRMWLIH5VSNIGXW
months ourselves. Excellent idea
06. A nice bit of hacking and upcycling – we 03
like it
02
07. More data is always better
08. This interactive pal looks like it’s going to
eat our 10p coins
09. ISS tracking on little screens is popular!
The API is quite readily available after all

86 magpi.cc #MagPiMonday
THIS MONTH IN RASPBERRY PI

04

05

06

07
08

09

#MagPiMonday magpi.cc 87
THIS MONTH IN RASPBERRY PI

Events in pictures:
Raspberry Jam WV
Community and official events in the wild

W
ay back in issue 79 of The MagPi, 01
we spoke to Brett White about EX T
OU T N D
how he has been trying to get UT AB N
FIND O ’S EVEN TS A
H
more computer science education into his MON T P O N
home state of West Virginia in the US. Since
POP-U
then, he’s been putting on Raspberry Jams PAGE 92
and is now a professor at the University of
Charleston’s Computer Science department. In
8L]NS_ST^dPL]_SPʭQ_S=L^[MP]]d5LXBA
went ahead – here are some photos. 02

01. Brett organises the Raspberry Jams, with 2022’s


being so good he became a professor
02. Programming and hacking Minecraft remains a
popular Jam activity
03. Various kinds of making equipment were
on display
04. You could also buy all manner of components for
]SYVS[RTVSNIGXW
05. ;LEXOMRHSJTVSNIGXWMRHIIHƳ[ILEZIWIZIVEPMR
this mag you can try

03 05

04

88 magpi.cc Events in pictures


THIS MONTH IN RASPBERRY PI

Crowdfund this!
Raspberry Pi projects you can
crowdfund this month

PiBeam
Make-It-Move HAT
“Step into the future with us and witness the birth of a device that
seamlessly merges the unrivalled computing power of Raspberry “Make-It-Move HAT is the most user-friendly plug-n-play custom
Pi’s RP2040 microcontroller with the wireless capabilities of hardware, that eases the development of motor driven Robotics
an IR transceiver. PiBeam is not just an ordinary gadget; it’s Applications. It provides an easy plug-n-play support to control up
a technological marvel, enabling you to explore the endless to 23 motors for any robotics Application, with easy to understand
possibilities of Python-based hardware learning.” ŸĜĵŞĬĜĀåÚÏŅÚå±ĹÚXĜÆų±ųĜåŸĜĹĵƚĬƋĜŞĬåX±Ĺčƚ±čåŸţŰ

kck.st/43klhJi kck.st/43DPAKB

Together we can
make a difference
Give young people the opportunity
to learn about technology

The Raspberry Pi Foundation enables young


people to realise their full potential through
the power of digital technologies, but we can’t
do this work without your help. Your support
helps us give young people the opportunities
they need in today’s world. Together we can
offer thousands more young people across
the globe the chance to learn to create with
digital technologies.
Generous donations from organisations and DONATE NOW
individuals who share our mission make our
work possible.

Donate today to make a difference: rpf.io/magpidonate


YOUR LETTERS

Your
Letters
Learn all about the construction
Centre of media SJE7EWTFIVV]5MMR/IǺƶWZMHIS

I’m considering using


Raspberry Pi for a
home media centre
setup. Are there any BUILD A RASPBERRY PI
step-by-step guides MEDIA PLAYER
Power up your TV and music system
or tutorials available
that cover the process
of setting up a media
centre using Raspberry
Pi? I’m particularly
interested in options
for streaming FROM THE MAKERS OF THE OFFICIAL RASPBERRY PI MAGAZINE

media, managing a There are many projects in here that


media library, and will help improve how you watch
and listen
integrating with
popular streaming platforms. Any recommendations
QZ]SL]ObL]PLYO^ZQ_bL]PNZYʭR`]L_TZY^bZ`WOMP
greatly appreciated.
Grand tour
Sean via email
I saw this video of a tour of the factory in Wales where Raspberry
We have a fantastic free PDF called ‘Build a Raspberry Pi is made and it was fascinating – when is the next available
Pi Media Player’ that includes some of our most factory tour, so people can see where the magic happens?
comprehensive tutorials for media centres, sound
systems, retro gaming machines, and more. It even has Kyle via Twitter
tips on how to use streaming services as well! Find it at
magpi.cc/mediaplayer. @YQZ]_`YL_PWd_SPaTOPZ_SL_5Pʬ2PP]WTYRXLOPbSTNSdZ`NLY
ʭYOSP]P%magpi.cc/tour) was done under special arrangement by
Sony, so it’s not something everyone can do. The tour is pretty
NZX[]PSPY^TaP_SZ`RS^ZWTaTYRaTNL]TZ`^Wd_S]Z`RS5PʬT^YZ__SP
worst idea.

90 magpi.cc Your Letters


USA SPECIAL!
6 ISSUES
FOR $43
APL of my eye
This is a note for Lucy Hattersley about her article
called ‘A retro world tour’ [Ed- Last month’s Final
Word piece]. It was a great article about the early
days of personal computing. In it, Lucy mentioned
that she had never heard of APL. APL is a fantastic
programming language that was created in the
early 1960s... APL is currently available from a
company called Dyalog at no cost for personal use.

Jim via email

APL is a very
interesting style of
code and it’s good
to know it’s still FREE
around and being
used! We may have RASPBERRY PI
to do a tutorial with
it in the future. PICO W

Contact us!
>
>
Twitter
Facebook
@TheMagPi
magpi.cc/facebook
Subscribe online:
>
>
Email
Online
magpi@raspberrypi.com
forums.raspberrypi.com
magpi.cc/subscribe

Subscription is for the next six issues by continous credit card and renews automatically. This is a
limited offer. Offer subject to change or withdrawal at any time.
EVENTS

Community
Events Calendar
Find out what community-organised Raspberry
Pi-themed events are happening near you…

01. Cornwall Tech Jam 04


Saturday 1 July
FibreHub, Pool, UK
magpi.cc/ctj131
Cornwall Tech Jams are run by volunteers working in IT
and education throughout Cornwall. They are supported
by Software Cornwall, its members, and other local
businesses. Our volunteers give their own time and
expertise to plan each Cornwall Tech Jam and to the 03. Southend Raspberry Jam Maker Meetup
regular maintenance of all our equipment. Saturday 15 July
Southend Library, Southend-on-Sea, UK
magpi.cc/srjmm131
This Raspberry Jam community event is hosted at
Southend Library and they’re looking to organise more FULL CALENDAR
regular activities such as workshops, project demos, Get a full list of upcoming
and larger meetups. Join the group and learn about ÏŅĵĵƚĹĜƋƼåƴåĹƋŸƤĘåųå×

opportunities to build technology projects, help at magpi.cc/events


or run workshops, or build alongside other makers
02. Melbourne Raspberry Pi Meetup and companies.
Sunday 2 July
Docklands Makerspace and Library, 04. Newark and LATeRe at FIEE
Melbourne, AUS Tuesday 18 July to Friday 21 July
magpi.cc/mrpm130 São Paulo Expo, São Paulo, Brazil
This meetup is open to everyone with an interest in magpi.cc/fiee
electronics, robotics, home automation, 3D printing, laser LATeRe, Brazil’s exclusive representative for Newark
cutting, amateur radio, high altitude balloons, space tech, Electronics, will be exhibiting at FIEE in São Paulo in
etc. Makers are invited to bring along their projects and July. They’ll be showcasing Raspberry Pi 4 computers,
project ideas, and come connect with other makers. Get Raspberry Pi Compute Modules, RP2040 microcontroller
]SYVUYIWXMSRWERW[IVIHWLS[SǺXLI[SVO]SYEVIHSMRK chips, and Raspberry Pi Pico series microcontrollers. You’ll
and get support to resolve nagging issues. ǻRHXLIQEXFSSXL++.**VIKMWXVEXMSRMWVIUYMVIH

92 magpi.cc Community Events Calendar


EVENTS

RASPBERRY PI 02
STORE POP-UP

9JGTGECP[QWƓPF
Raspberry Pi next?
> Next location Raspberry Pi Store pop-up, Gateshead
> Where Metrocentre, Gateshead, UK
> When Friday 28 July and Saturday 29 July

A
t this Raspberry Pi Store pop-up
in Gateshead, you can experience
and buy Raspberry Pi products.
Explore some of the things you can do with
03 a Raspberry Pi, discover our accessories
and books, and get your hands on limited
edition exclusives.
01
magpi.cc/popup2023gateshead

Community Events Calendar magpi.cc 93


Your FREE guide to
making a smart TV

BUILD A RASPBERRY PI
MEDIA PLAYER
Power up your TV and music system

FROM THE MAKERS OF THE OFFICIAL RASPBERRY PI MAGAZINE

magpi.cc/mediaplayer
COMPETITION

WIN ONE OF TWO


ARGON
POD SETS
IN ASSOCIATION
WITH ARGON40
The Argon POD system is a
modular case for Raspberry Pi
Zero that allows you to build up
and add functionality, depending
on your needs. As well as
adding Ethernet support, you
can also convert the micro USB
and mini HDMI to their full-size
alternatives, and we have two
complete sets to give away.

Head here to enter: magpi.cc/win


Learn more: magpi.cc/argonpod

Terms & Conditions


Competition opens on 28 June 2023 and closes on 27 July 20235VM^IMWSǺIVIHXSTEVXMGMTERXW[SVPH[MHIEKIHSVSZIVI\GITXIQTPS]IIWSJ7EWTFIVV]5M1XHXLITVM^IWYTTPMIV
XLIMVJEQMPMIWSVJVMIRHW;MRRIVW[MPPFIRSXMǻIHF]IQEMPRSQSVIXLERHE]WEJXIVXLIGSQTIXMXMSRGPSWIW']IRXIVMRKXLIGSQTIXMXMSRXLI[MRRIVGSRWIRXWXSER]TYFPMGMX]
KIRIVEXIHJVSQXLIGSQTIXMXMSRMRTVMRXERHSRPMRI5EVXMGMTERXWEKVIIXSVIGIMZISGGEWMSREPRI[WPIXXIVWJVSQ8LI2EK5MQEKE^MRI;IHSRƶXPMOIWTEQTEVXMGMTERXWƶHIXEMPW[MPP
VIQEMRWXVMGXP]GSRǻHIRXMEPERH[SRƶXFIWLEVIH[MXLXLMVHTEVXMIW5VM^IWEVIRSRRIKSXMEFPIERHRSGEWLEPXIVREXMZI[MPPFISǺIVIH;MRRIVW[MPPFIGSRXEGXIHF]IQEMPXSEVVERKI
HIPMZIV]&R][MRRIVW[LSLEZIRSXVIWTSRHIHHE]WEJXIVXLIMRMXMEPIQEMPMWWIRX[MPPLEZIXLIMVTVM^IVIZSOIH8LMWTVSQSXMSRMWMRRS[E]WTSRWSVIHIRHSVWIHSVEHQMRMWXIVIHF]
SVEWWSGMEXIH[MXL.RWXEKVEQ+EGIFSSO8[MXXIVSVER]SXLIVGSQTERMIWYWIHXSTVSQSXIXLIWIVZMGI

Competition magpi.cc 95
SAVE
35%

ISSUE #68

OUT NOW
hsmag.cc
NEXT MONTH

EDITORIAL
Editor
Lucy Hattersley

RETRO
lucy@raspberrypi.com
Features Editor
Rob Zwetsloot
rob@raspberrypi.com
Sub Editor
Nicola King

ADVERTISING

GAMING
Charlotte Milligan
charlotte.milligan@raspberrypi.com
+44 (0)7725 368887

DESIGN
criticalmedia.co.uk

Head of Design
Lee Allen

+ OFFICE WORK
Designers
Olivia Mitchell, Sam Ribbits
Illustrator

WITH
Sam Alder

CONTRIBUTORS
RASPBERRY PI David Crookes, Rosemary
Hattersley, Nicola King, Phil
King, Dr. Andrew Lewis, KG
Orphanides, David Plowman,
Danny Staple, Stewart Watkiss

PUBLISHING
Publishing Director
Brian Jepson
brian.jepson@raspberrypi.com
Director of Communications
Liz Upton
CEO
Eben Upton

DISTRIBUTION
Seymour Distribution Ltd
2 East Poultry Ave,
London EC1A 9PT
+44 (0)207 429 4000

SUBSCRIPTIONS
Unit 6 The Enterprise Centre
Kelvin Lane, Manor Royal,
Crawley, West Sussex, RH10 9PE
+44 (0)1293 312193

THE MAGPI #132


magpi.cc/subscribe
magpi@subscriptionhelpline.co.uk

ON SALE 27 JULY This magazine is printed on paper sourced


from sustainable forests and the printer
operates an environmental management

Plus! DON’T MISS OUT!


system which has been assessed as
conforming to ISO 14001.
The MagPi magazine is published by

Star Wars magpi.cc/subscribe


Raspberry Pi Ltd, Maurice Wilkes Building,
St. John’s Innovation Park, Cowley Road,

diorama Cambridge, CB4 0DS. The publisher,


editor, and contributors accept no
responsibility in respect of any omissions

Paragraphica AI or errors relating to goods, products, or


services referred to or advertised in the

lens-free camera @TheMagPi magazine. Except where otherwise noted,


content in this magazine is licensed under
a Creative Commons Attribution-
fb.com/MagPiMagazine
Pipstrelle Bat NonCommercial-ShareAlike
3.0 Unported

Detector magpi@raspberrypi.com (CC BY-NC-SA 3.0).


ISSN: 2051-9982.
THE FINAL WORD

Tech in front of our eyes


Virtual reality is in the news, but physical making is the real deal!
By Lucy Hattersley

T
he future is amongst us. At least feels like the tech industry is getting if it’s a serious project or a piece of
according to Apple, purveyor of ready to limber back up. whimsy. What matters most is that
shiny slabs, which recently =L^[MP]]d;TT_^PWQT^^SLVTYRZʬ_SP it’s real.
announced a new glass headset to PʬPN_^ZQ_SP^`[[WdNSLTY[]ZMWPX^ The future appears one day and
slap in front of your face. You can dial that have plagued everybody for the then suddenly it’s the present. It feels
back reality using a rotating tool on last couple of years. There is no like ChatGPT and the AI generative
the side, and tap apps and icons in steady supply of Raspberry Pi Zero, genie are out of the bottle and will be
mid-air. Sounds fun. Raspberry Pi 3A+, and an increasing staying with us, for now. I suspect
I’m not convinced by VR or AR. supply of Raspberry Pi 4 models. we’ll also see a lot more generated AI
Does the future of technology really art and 3D visuals. Personally, I hope
belong to this kind of detachment Back in the room that it’ll be the mundane but useful
from reality? Who knows! Maybe I’ll This comes as a big relief to us. We’re technology, the sort that pings me for
have egg on my face and a Vision Pro keenly aware that people love this calendar events and lets me know
headset in three years. I’ll be writing magazine because they love Raspberry when my partner is calling, but then
this with giant hovering buttons in Pi. And it’s easier to love something fades into the background when I’m
front of my face while you read it, in that you can reliably buy. looking at more interesting things.
Maybe VR and AR are the future,
but I need to assemble it with my own
Maybe, when I’m hooking up dual tiny two hands for it to feel real. There
have been some attempts at VR with
screens inside a 3D-printed headset, it’ll Raspberry Pi, and with its dual HDMI

suddenly feel real to venture into an output, there is potential for VR


projects with our little board

open-source virtual world computer. Maybe, when I’m hooking


up dual tiny screens inside a
3D-printed headset, it’ll suddenly feel
thirty-foot-high letters being beamed This brings us back to this weird real to venture into an open-source
into your retinas from an inch away. virtual world that Apple seems to be virtual world. Until then, I’ll be
I’ll bet not though. I’ll be happily pushing for. I don’t believe that real sticking with actual reality.
playing with Raspberry Pi computers tech people want to point and tap into
and building ever more advanced empty space. For me, the joy of
Lucy Hattersley
AUTHOR

robots and projects. computing is linked to the real world.


Still, there’s a lot going on in the It’s physical things you can pick up,
Lucy is editor of The MagPi and is
tech industry at the moment. From hold, and use. Actual computers with GYVVIRXP]GEYWMRKERSǽGIOIVJYǾIXLEX
strident leaps in AI (speaking of wires and buttons and solder. WLIGERƶXXEPOEFSYX2E]FIXLEX:7
which, have you seen GitHub Copilot?) Building an arcade machine, robot, or IWGETIMWRƶXWYGLEFEHMHIEEJXIVEPP

through to shiny new Apple toys, it earthquake detector. It doesn’t matter magpi.cc/lucyhattersley

98 magpi.cc Tech in front of our eyes


The new case from the HiPi.io team

Rapid tool-free assembly and disassembly Secure microSD card cover


Large internal volume for HATs VESA mount support
Compatible with Pi 2/3/4 Molding-configurable output ports
Multiple lid options customizable for volume orders
Passive & Active Cooling options Printed logo for your branding

Available at these great Pi stores:

Contact your favorite Pi store if it’s not listed here


.BOBHFZPVSTFSWFSTPS
XPSLTUBUJPOTSFNPUFMZ

"DPTUFŗFDUJWFTPMVUJPOGPSEBUBDFOUFST 
*5EFQBSUNFOUTPSSFNPUFNBDIJOFT

1J,7.)"5
GPS%*:BOEDVTUPNQSPKFDUT 1SF"TTFNCMFEWFSTJPO

3FBMUJNFDMPDLXJUISFDIBSHFBCMFTVQFSDBQBDJUPS 0-&%%JTQMBZ #PPUBCMFWJSUVBM$%30.


ŚBTIESJWF 4FSJBMDPOTPMF 0QFOTPVSDF"1*JOUFHSBUJPO 0QFOTPVSDFTPGUXBSF

$YDLODEOHDWWKHPDLQ5DVSEHUU\3LUHVHOOHUV

3FTFMMFSTVHHFTUJPOTBOEJORVJSJFT
XIPMFTBMF!IJQJJP

You might also like