Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore MagPi68

MagPi68

Published by gPiO Box, 2018-05-26 04:54:59

Description: Raspberry Pi 3B+. We fully benchmark the faster Raspberry Pi 3B+. Includes an interview with the engineering team and amazing project ideas for the faster computer.
Build Amazing Battle Robots. Get ready for Pi Wars 2018 with our guide to winning the Raspberry Pi robotic competition.
Create a Raspberry Pi smart fan. Keep your cool by hacking a fan with a Raspberry Pi.
The Pi Switch. Hack Nintendo Switch Joy-Cons to work with a Raspberry Pi retro gaming system.
Code a Minecraft House. Build your own house in Minecraft with Python.
And much, much more

Search

Read the Text Version

BEGINNER’S GUIDE TO DOCKER ON RASPBERRY PI TutorialFigure 4 Downloading the Plex image and startinga Docker container takes just two commands!and exited. Give it a try and have some fun changing following screen with ‘Plex Server Setup’, click Next Figure 5 Setting to go to the media libraries configurator. up Plex withthe quoted text to something else. media libraries; Press the ‘Add library’ button (Figure 5) and pick ‘Films’, ‘Music’, andDo something useful with Docker the Films library type, then Next, and then ‘Browse ‘Photos’ are added for media folder’. Click the /media directory and and ready to useDocker simplifies applications and it may seem that select the movies folder inside it, then click Add and then ‘Add library’. Repeat this with a Music and ACCESSINGfor things we’ve tried earlier it doesn’t make much of Photos library, pointing towards music and pictures YOUR directories respectively. RASPBERRYa difference. Now we’re going to do something really PI REMOTELY After configuring the libraries, click Next anduseful that would be very complicated otherwise: set Done on the following screen, and the Plex dashboard You can access screen will load. Click Settings on the left-hand the Raspberryup a Plex media server, which lets you stream your side menu, find the Library menu and tick ‘Update Pi remotely my library automatically’ and ‘Update my library from anothermovies, music, and pictures anywhere on any device. periodically’ options, then click ‘Save changes’. Now computer First, pull the Plex image with docker pull you are all set up! Click the home icon in the top-left using SSH. corner to get back to the dashboard. How to do thatjaymoulin/plex. Then download a multimedia set depends onprepared for this tutorial: wget https://magpi.cc/ You can now watch media files from these your operatingplex-media -O /tmp/plex-media and unpack with libraries from a browser on any computer using the system, butsudo tar xvzf /tmp/plex-media -C /media. As same wireless network as your Raspberry Pi with you cana last step, run the Plex container: docker run -d Docker. There are Plex applications available for tablets find more--restart=always --name=plex -v=/media:/ and smartphones for streaming on mobile devices too! informationmedia --net=host jaymoulin/plex. about it here: There is much more to containers, Docker, and magpi.cc/ That command performs a series of events. First, Hypriot. To learn more, and even how to build your 1GULmTr own containers, check out magpi.cc/CmofXu andit orders Docker to run the application in background magpi.cc/wvohdL. Happy dockerising!with a -d flag, then restart it automatically if itexists with a --restart=always flag. It then assignsthe container name with --name=plex instead ofa random one, connects the /media folder on theRaspberry file system to a folder of the same nameinside the container with -v=/media:/media, sets thecontainer network to use Raspberry’s IP address with--net=host, and finally specifies the jaymoulin/plex container image to use. Check if the container isrunning fine with the docker ps command and youshould see output like that in Figure 4. Plex is now installed and running, so youcan configure it. Open http://[YOUR_IP_ADDRESS]:32400/web/index.html in a browser,where you replace YOUR_IP_ADDRESS with yourRaspberry Pi’s IP address discovered earlier (e.g.,http://192.168.168.135:32400/web/index.html). The Plex setup screen will open, where it will askyou to create an account. Skip this by clicking onthe ‘What’s this?’ link in the bottom-right corner,then click ‘Skip and accept limited functionality’ atthe bottom of the next screen. Click ‘Got it!’ on thenext screen and close the ‘Plex pass’ pop-up. On theraspberrypi.org/magpi April 2018 51

Tutorial STEP BY STEP JEROEN PETERS Jeroen spends his day back-end developing for Yourhosting and loves to create open-source projects (mostly) by night. magpi.cc/MuQCYYKEEP COOL WITH API-POWERED FANYoNue’leld Sitting behind a desk can be very stressful at times, but with some clever code and a USB fan, you’ll be able to keep your cool> 3.5-inch touchscreen N othing is as personal as the level of comfort up the temperature sensor using the PiFan wiring and case someone feels. In shared office spaces it’s diagram in Figure 1. magpi.cc/ almost impossible to create a climate in which bpWaTO everyone feels comfortable, especially when these >STEP-02 shared spaces are large. With about 40–50 people in a> DHT22 sensor room, we can’t all be happy. We’ve put together some Attach the other components (on PCB) components, both hardware and software, to keep us magpi.cc/rVJjfJ cool. Here’s how you can do the same… After you’ve attached the sensor, mount the display on the Raspberry Pi. It slots nicely on top of the> U SB fan >STEP-01 GPIO pins, so this should be easy. Now you can build magpi.cc/ the acrylic case around it to support the display and gTcRve Wire up the sensor protect your Raspberry Pi. Of course, you should make sure the sensor stays on the outside of the case.MAKE First things first: this project is all about monitoring After completing the case, plug the USB fan into yourCITHEEVAEPNER temperature, so we need to attach the sensor. It’s Raspberry Pi. If your USB fan has a power switch, hit it important to do this before attaching the display. Wire to make sure it works.Although theDHT22 and When the offset is passed, The current temperature ismini table-fan the USB port will be powered measured constantly andare relatively and the fan turns on compared to the offsetcheap, youcan also usea DHT11 anda simpleUSB fan.52 April 2018 raspberrypi.org/magpi

KEEP COOL WITH A PI-POWERED FAN Tutorial>STEP-03 Figure 1 This diagram shows you how toSet up the OS and display attach the sensor to the GPIO headerThe manufacturer of this screen has an image ofRaspbian (with Raspberry Pi Desktop) available, whichhas the display driver built in. You can download it toburn to an SD card from magpi.cc/aNmzpT. Followour guide to burn SD cards here: magpi.cc/2fZkyJD. If you want to install the driver manually, or haveanother type of screen, that’s no problem. Just be sureto use Raspbian with the Raspberry Pi Desktop so thatChromium is available.>STEP-04Download the softwareOpen the Terminal (or dial in with SSH from anothercomputer) to install and download all of the software.We’ll start with the prerequisites. Install them withthe command:sudo apt-get install nginx-light supervisor git build-essential python-dev python-pip Also install the Python framework Falcon mkdir -p /home/pi/.config/autostartby executing: cd /home/pi/.config/autostartsudo pip install falcon==1.0.0 Now clone and install the sensor module driver: Within this directory, create a file called AutoChromium.desktop:git clone https://github.com/adafruit/ Adafruit_Python_DHT.git /tmp/dht sudo nano AutoChromium.desktopcd /tmp/dht Then type in the following:sudo python setup.py install Now clone the PiFan GitHub repo with the [Desktop Entry]following command: Type=Application Exec=/usr/bin/chromium-browser --noerrdialogsgit clone https://github.com/ jeroenpeters1986/piFan.git /home/pi/pifan --disable-session-crashed-bubble --disable-infobars --disable-translate All software needed will now be on the Raspberry Pi. --kiosk http://127.0.0.1 Hidden=false>STEP-05 X-GNOME-Autostart-enabled=true Name=AutoChromiumConfigure the software Now save the file and reboot the Raspberry Pi, so you canWe now need to configure the software we just see if it worked.downloaded. The following commands will configurethe web server and create three processes that will be >STEP-06 SHUT ITsupervised (so they are always available): DOWN Customise your PiFan CORRECTLYsudo rm /etc/nginx/sites-enabled/defaultcd /home/pi/pifan/config If you know a thing or two about HTML and CSS, and Tap the fan-sudo cp nginx-sites-enabled-default a little bit about JavaScript, you can customise the guy in the interface yourself! There is only one HTML file you top-left and /etc/nginx/sites-enabled/default can edit. In there, you’ll also see the JavaScript and the PiFan textsudo cp supervisor-* /etc/supervisor/conf.d/ CSS references. To customise the PiFan touch interface, is highlighted. edit the /home/pi/pifan/webinterface/index.html Tap this text The last requirement is to autostart Chromium with file. Once you have made changes, tap the refresh to engagethe interface. Create the autostart folder and change button on the top-right of your touchscreen to see a properdirectory to it: your changes. shutdown.raspberrypi.org/magpi April 2018 53

Tutorial WALKTHROUGH STEVE MARTIN Steve has worked in the software industry for 25 years and runs a Code Club at Longlevens Library in Gloucestershire. twitter.com/0x90_BugYoNue’leld BUILD A HOUSE IN> Minecraft Pi MINECRAFT> An idea for a USING PYTHON great house> A keyboard Get creative with Minecraft on the Raspberry Pi and learn to program in Python by building your own house W riting programs that create things in Minecraft program than to build one house, once finished you can is not only a great way to learn how to code, but build as many houses as you want. it also means that you have a program that you Co-ordinates in Minecraft can run again and again to make as many copies of your Let’s start with a review of the co-ordinate system that Minecraft uses to know where to place blocks. design as you want. You never need to worry about your If you are already familiar with this, you can skip to the next section. Otherwise, read on. creation being destroyed by your brother or sister ever again when you can simply rerun your program and get it back. Whilst it might take a little longer to write the54 April 2018 raspberrypi.org/magpi

BUILD A HOUSE IN MINECRAFT USING PYTHON Tutorial Figure 1 This is the plan view of the house. Note that it We will build our house close to where the Minecraft Figure 2 This has a door on one side and windows on all four sides player is standing. This a good idea when creating initial shell of the something in Minecraft with Python, as it saves us house is already Minecraft shows us a three-dimensional (3D) view from having to walk around the Minecraft world to complete. Smashof the world. Imagine that the room you are in is in try to find our creation. Right, let’s get coding. through one of thethe Minecraft world and you want to describe your walls to make surelocation within that room. You can do so with three Starting our program that the house isnumbers, as follows: hollow inside Type in the code as you work through this tutorial. How far across the room you are. As you move from You can use any editor you like; we would suggestside to side, you change this number. We can consider either Python 3 (IDLE) or Thonny Python IDE, boththis value to be our X co-ordinate. of which you can find on the Raspberry Pi menu under Programming. Start by selecting the File menu and How high off the ground you are. If you are upstairs, creating a new file. Save the file with a name of youror if you jump, this value increases. We can consider choice; it must end with ‘.py’ so that the Raspberry Pithis value to be our Y co-ordinate. knows that it is a Python program. How far into the room you are. As you walk It is important to enter the code exactly as itforwards or backwards, you change this number. is shown in the listing (house-complete.py).We can consider this value to be our Z co-ordinate. Pay particular attention to both the spelling and capitalisation (upper-or lower-case letters) used. You might have done graphs in school with X going You may find that when you run your program theacross the page and Y going up the page. Co-ordinates first time, it doesn’t work. This is very common andin Minecraft are very similar, except that we have just means there’s a small error somewhere. The erroran extra value, Z, for our third dimension. Don’t message will give you a clue as to where the error is.worry if this still seems a little confusing: once westart to build our house, you will see how these three It is good practice to start all of your Pythondimensions work in Minecraft. programs with the first line as shown in our listing. All other lines that start with a ‘#’ are comments.Designing our house These are ignored by Python, but they are a good way to remind us what the program is doing.It is a good idea to start with a rough design for ourhouse. This will help us to work out the values for the The two lines starting with from tell Python aboutcoordinates when we are adding doors and windows the Minecraft API; this is a library that our programto our house. You don’t have to plan every detail of will be using to talk to Minecraft. The line starting mc =your house right away. It is always fun to enhance it creates a connection between our Python program andonce you have got the basic design written. Figure 1 the game. Then we get the player’s location brokenshows the plan view of the house design that we will down into three variables: x, y, and z.be creating in this tutorial. Note that because this isa plan view, it only shows the X and Z co-ordinates; Building the shell of our housewe can’t see how high anything is. Hopefully you canimagine the house extending up from the page. To help us build our house, we define three variables that specify its width, height, and depth. Defining these variables makes it easy for us to change the size of our house later; it also makes the code easier to understand when we are setting the co-ordinates of the Minecraft bricks. For now, we suggest that you use the same values that we have; you can go back andraspberrypi.org/magpi April 2018 55

Tutorial WALKTHROUGHhouse-complete.py#!/usr/bin/env python3from mcpi.minecraft import Minecraftfrom mcpi import block# Connect to Minecraftmc = Minecraft.create()# Determine the Player's current position.x,y,z = mc.player.getTilePos()width = 5 Figure 3 The house now has a door and cobblestoneheight = 3 floor. It is already possible to walk insidedepth = 6 Language# Create a hollow shell made of bricks.mc.setBlocks(x, y, z+3, x+width, y+height, z+3+depth, block.BRICK_BLOCK.id) >PYTHON 3mc.setBlocks(x+1, y, z+4, x+width-1, y+height-1, z+2+depth, block.AIR.id) DOWNLOAD:# Set the floor.mc.setBlocks(x-1, y-1, z+2, x+1+width, y-1, z+4+depth, block.COBBLESTONE.id) magpi.cc/oRCLSD# Add a Door.mc.setBlock(x+1, y, z+3, block.DOOR_WOOD.id, 0)mc.setBlock(x+1, y+1, z+3, block.DOOR_WOOD.id, 8)# Add Windows.mc.setBlocks(x+3, y+1, z+3, x+4, y+2, z+3, block.GLASS.id)mc.setBlocks(x+2, y+1, z+3+depth, x+3, y+2, z+3+depth, block.GLASS.id)mc.setBlocks(x, y+1, z+5, x, y+2, z+7, block.GLASS.id)mc.setBlocks(x+width, y+1, z+5, x+width, y+2, z+7, block.GLASS.id)# Add a Roof.for i in range(int(width/2) + 1): mc.setBlocks(x+i, y+height+i, z+3, x+i, y+height+i, z+3+depth, block.STAIRS_WOOD.id, 0) mc.setBlocks(x+width-i, y+height+i, z+3, x+width-i, y+height+i, z+3+depth, block.STAIRS_WOOD.id, 1) # Gable ends. if (int(width/2) - i > 0): mc.setBlocks(x+1+i, y+height+i, z+3, x+width-i-1, y+height+i, z+3, block.BRICK_BLOCK.id, 0) mc.setBlocks(x+1+i, y+height+i, z+3+depth, x+width-i-1, y+height+i, z+3+depth, block.BRICK_BLOCK.id, 1) change the values once the house is complete and you We have to work out the values that we need to use in want to alter its design. place of x1, y1, z1, x2, y2, z2 for our walls. Note that what we want is a larger outer block made of bricks and then It’s now time to start placing some bricks. We to fill it with a slightly smaller block of air blocks. Yes, in create the shell of our house with just two lines of Minecraft even air is actually just another type of block. code! These lines of code each use setBlocks to create a complete block of bricks. This function takes the Once you have typed in the two lines that create following arguments: the shell of your house, you should run your program. Before doing so, you must have Minecraft running setBlocks(x1, y1, z1, x2, y2, z2, block-id, data) and displaying the contents of your world. Do not have a world loaded with things that you have created, x1, y1, z1 are the co-ordinates of one corner of the as they may get destroyed by the house that we are block of bricks that we want to create; x2, y2, z2 are building. Go to a clear area in the Minecraft world the co-ordinates of the other corner. The block-id before running the program. When you run your is the type of block that we want to use. Some blocks program, check for any errors in the ‘console’ window require a further data value; we will see that being and fix them before continuing trying to run it again used later, but it can be ignored for now. until all the errors have been fixed.56 April 2018 raspberrypi.org/magpi

BUILD A HOUSE IN MINECRAFT USING PYTHON Tutorial You should see a block of bricks created, as shown Adding a roofin Figure 2. You may have to turn the player around inthe Minecraft world before you can see your house. The final stage is to add a roof to the house. To do this we are going to use wooden stairs. We will do thisAdding the floor and door inside a loop so that if you change the width of your house then more layers are added to the roof. EnterNow, let’s make our house a bit more interesting. the rest of the code. Be careful with the indentation:Add the lines for the floor and door. Note that the we recommend using spaces and avoiding the usefloor extends beyond the boundary of the wall of the of tabs. After the if statement, you need to indenthouse; can you see how we achieve this? Hint: look the code even further. We use four spaces for eachclosely at how we calculate the x and z attributes as indentation level, so after the line with if on it youcompared to when we created the house shell above. will need eight spaces for the indent.Also note that we use a value of y-1 to create the floorbelow our feet. Since some of these code lines are lengthy and heavily indented, you may well find that the text Minecraft doors are two blocks high, so we have to wraps around as you reach the right-hand side of yourcreate them in two parts. This is where we have to use editor window – don’t worry about this. You will havethe data argument. A value of 0 is used for the lower to be careful to get those indents right, however.half of the door, and a value of 8 is used for the upperhalf (the part with the windows in it). These values Now run the complete program. Iron out any lastwill create an open door. If we add 4 to each of these bugs, then admire your house. Does it look how youvalues, a closed door will be created. expect? Can you make it better? Run your program again to check that the floor and Customising your housedoor are created (Figure 3). Before you do so, move to anew location in Minecraft to build the house away from Now you can start to customise your house. It is a goodthe previous one. You will need to fix any errors. Even idea to use ‘Save As’ to save a new version of yourwhen your program runs without errors, check that the program so that you can keep different designs, orfloor and door are positioned correctly. If they aren’t refer back to your previous program if you get to a pointthen you will need to check the arguments to setBlock where you don’t understand why it doesn’t work.and setBlocks are exactly as shown in the listing. Consider these changes:Adding windows Change the size of your house. Are you able also toHopefully you will agree that your house is beginning move the door and windows so they stay in proportion?to take shape. Now let’s add some windows. Looking Change the materials used for the house. An iceat the plan for our house, we can see that there is a house placed in an area of snow would look really cool!window on each side; see if you can follow along. Add Add a back door to your house. Or make the front doorthe four lines of code, one for each window. a double-width door. Now you can move to yet another location and run We hope that you have enjoyed writing this programthe program again; you should have a window on each to build a house. Now you can easily add a house toside of the house (Figure 4). Now our house is starting your Minecraft world whenever you want to, just byto look pretty good! running this program. Figure 4 The windows have been added on all four sidesraspberrypi.org/magpi April 2018 57

Tutorial WALKTHROUGH BRIAN BEUKEN Very old game programmer now teaching very young game programmers a lot of bad habits at Breda University of Applied Science in Breda NL. scratchpadgames.netCODING GAMESON THE RASPBERRY PIIN C/C++ PART 04YoNue’leld If coding is about manipulating data, let’s manipulate some data> C ode::Blocks T he graphics in our game so far are nice, but a of Cartesian x-y co-ordinates, which represent pixels sudo apt- bit simple and fixed. Also, we only have one in that space. get install graphic. This can be easily fixed by making our codeblocks CPU do what a CPU is designed to do, which makes Another slight issue is that our ‘squares’ are not our life a lot easier. We also need to try to make the actually square – they are rectangular. That’s because> STB creation and use of graphic objects easier and more our concept of -1.0f to +1.0f is considered to be a ratio magpi.cc/ flexible. Let’s begin. of each axis of the clip space, which we set to be a 2GCQe19 We mentioned last time that all programming rectangular size when we defined our screen sizes. is about manipulating data based on conditions or Our images also use those ratios, so they become mini> A pretty picture; needs. Let’s consider a possible need we have and rectangles like the screen. not too big think about how we can manipulate the data. At the moment we move our squares based on So it’s clear we need to do something to turn theseREAD values -1.0f to +1.0f on the x and y axes. This gives ratio values into simple pixel co-ordinates and get ridTHE CODE us a rather cumbersome way of working out their of this rectangular distortion. position on the screen; we can only really be sureThere are of the centre 0,0 position and the edges. This is all We have to keep in mind that our GPU thinks incomments and because of the way our GPU thinks about the buffer terms of clip space, so when it draws, it will needdescriptions in it draws graphics in, called the clip space. For a to use a clip space value. If ‘we’ want to use pixelthe code that GPU, it makes sense to use a value that represents a co‑ordinates, we have to transform them into ratiosexplain what ratio of the size of its clip space buffer; for a human, for the GPU to use.it is supposed though, we’re much more comfortable with the ideato do. So we have a need: we want to use pixel co‑ordinates and turn them into clip-space ratios when the GPU wants to use them. There are actually two ways to do this. We can do it in our draw code before we send the position value to the shader, using quite a simple sequence of steps; or, even cooler, we can do it in the shader itself. Which is best? Well that’s a really good question, because both systems will work. Ideally, we want to make it happen on the shader, because shaders love doing maths. To begin with, let’s do it on the CPU so we can be very sure about what is happening.Figure 1 An array holds data or pointers to data Time for maths! There’s no escaping the fact that manipulation of almost any data is maths, but it’s usually very simple maths; if you know how to do basic arithmetic, you can accomplish a lot of things.58 April 2018 raspberrypi.org/magpi

CODING GAMES ON THE RASPBERRY PI IN C/C++ Tutorial Language >C++ NAME: MagPiHelloTriangle. cpp, SimpleObj.h/cpp, Game.h/cpp, OGL.h/cpp DOWNLOAD: magpi.cc/PryrsN Here, all we want to do is turn a pixel value that is Figure 2 Nice and squareeasy for us to understand into a ratio that is easy forthe GPU to understand. This is a case of using the here we run into a bit of a quandary. Yes, we can do itpixel values and sizes we have and seeing them as in our CPU code, but if we’re trying to change data wefractions, which then become ratios. We have a slight send to the shader, wouldn’t it be better if the shadercomplication since the clip screen uses co‑ordinates changed the values?between -1.0f and +1.0f, and we really want to removenegatives. However, we know the width and height of Well, the answer is probably yes, but it does meanour screen, so in our update we can do this: we need to make changes to our shader, and pass information that allows it to convert screen-basedPos[0] = ((Xpos-512) / 512); co-ordinates to ratios.Pos[1] = ((Ypos-384) / 384); We know we pass information from code to the shader in uniforms, as we did with the ratio co‑ordinates. Let’s try sending info on the screen size, by modifying the shader and changing our Subtracting half the screen height or width, and There’s no escaping the factthen dividing the result by that half value enables us that manipulation of almostto move our co-ordinate systems to a bottom-left any data is mathsposition: 0,0. uniform send systems to pass position and Screen USE GOOD Now we can code that in our draw function, and Size data. Check out the new shader in the code for TOOLSchange our initialise and update systems to work on this lesson: magpi.cc/PryrsN.real pixel values instead of ratios. So, rather than We’re abouttest for -1.0f and +1.0f, test for 0 and SCREENWIDTH Now when we run these we get nice square objects, to make a 2Dfor the x direction, and 0 and SCREENHEIGHT but there’s one last thing we want: the ability to tile game, sofor the y direction. dictate their size. find a good tile editor: Try to make the changes in Lesson 3’s code, As our The MagPi logo was quite large, our current mapeditor.orguse co-ordinates in your update code, and convert triangle vertices are actually 0.1f offsets. This meansbefore the draw sends to the shader (you will also they are already one-tenth their natural size, but wefind it on the GitHub: magpi.cc/2suLVC2). You can might want to have them be any size. This is calledsee we are bouncing around still, but now we have scaling, and again it’s best done in the shader. Wea much easier-to-understand co-ordinate system now need to pass three things to the shader: thewhich allows us to think in pixel terms rather than co‑ordinates (as x and y pixel values), screen sizes,ratios. Our needs have been partially resolved; we and a scale value.still have our oblong shapes and another niggle:they’re the wrong size! Now, that is starting to sound like a lot of data to send, and it is. We can live with it for now, butHow to make it better ideally we should try to organise the data in a betterTo fix the oblong issue, we also need to change theratio-based offsets that make up the triangles, andraspberrypi.org/magpi April 2018 59

Tutorial WALKTHROUGH NEVER way. To this end, let’s consider a couple of data A 2D array can be thought of as rows of streets, with FORGET THE storage concepts. an extra identifier to indicate which row we want, as OIMFPGOOROTDANARCTE! well as the house identifier. Arrays and structs If you can’t float ArrayStreet2D[Which_Row][House]; draw, make Arrays are useful: they allow us to keep sequences of friends with data in order and accessible. There are actually several There’s a small downside to an array: it’s only able someone types of array, but we only need to use two types for to hold one type of info. So an array of floats means who can! now: single- and two-dimensional (2D) arrays. each ‘house’ can only contain float values, and an array of ints can only contain ints, and so on. We can Figure 3 A single-dimensional array is like a street of houses get round that, though, because it’s possible for us Let’s look at what’s (Figure 1), with each house containing some piece of to define our own info types, in something called a info we want, or allowing us to store or get info. The ‘struct’, short for structure. in box number house number tells us which house to go to, while the2DArrayStreet [3] [2] name allows us to access the correct street of houses. If you look at the code for this lesson (OGL.h) you will see how we define a struct. This is a really Figure 4 float ArrayStreet[10] ; // defines an useful concept and lets us define a new ‘type’ of user Now we can array with 10 float entries variables to suit our particular needs. print tiles So float value = ArrayStreet[2] tells us to Grouping important data in this way keeps it in nice from a grid go to house number 2 (actually the third house*) on handy chunks that can be stored easily and sent to the ArrayStreet and we can load value with whatever shader quite cleanly. we find in that house. Review the Lesson 4 code and comments to see * Note that array number systems don’t start at element 1, how we are storing and using the new simpleVec2 but element 0. This is known as base 0 indexing, since coders data type. regard the number 0 as having a useful value as an index. We’ll send pixel co-ordinates to the shader and let it do the maths, so in total we have to send two position floats, easily held in a simpleVec2, and two screen size values, also held in a simpleVec2, and finally a single float for scale in x and y. Figure 2 shows our use of the new shader with The MagPi logo, but Lesson 4 is now set up to use new tile graphics. Our objects are now square, we can scale their size, and they will stay square unless we decide to add separate x and y scale values. Creating a playfield We are now very close to having a working but still inefficient framework. We have a method where we can place objects in pixel co-ordinates. That allows us to place objects exactly where we want to. But it raises a question: what do we want to place? For now, we want to use tiles. We can now use square objects and set the size, which gives us a perfect opportunity to make use of a 2D array (Figure 3) to show a grid that has tile numbers, and relate them to screen positions. Check out the Game class update within the code. When it starts, it scans though our grid using two loops, and we create and place objects at a relative location on screen. As well as scanning the grid to make and store objects in a pre-prepared array, we find what tile graphics we need, load them, and then supply a tile with it (Figure 4). Again, it’s not actually very efficient, but we’ll fix that soon. Now, we have tiles and a playfield. Next time we are going to create sprites and interact with this new playfield, and talk about C++’s greatest challenge: handling memory.60 April 2018 raspberrypi.org/magpi



F.A.Q. YOUR QUESTIONS ANSWERED PNSROEEOLVDBELADE?MFREQUENTLY Email [email protected] or find us on raspberrypi.org/forumsASKED QUESTIONS to feature in a future issue.Your technical hardware and software problems solved…UPGRADING assuming you have the correct libraries installed to run them of course. All the tutorials and projectsTO A NEW PI you’ll find in past issues of The MagPi and on the Raspberry Pi website will continue working with SHOULD I UPGRADE MY a new Pi model. RASPBERRY PI? Similar hardware Want versus need HATs will still work on newer Raspberry Pi boards, If you’re happy with your so you’ll just need to transfer over any relevant current Raspberry Pi, there’s no configuration files to get them running. The new immediate need to upgrade. Most PoE HAT, though, is designed specifically for the tutorials and projects are made new Pi 3B+, so you won’t get it working on a Pi B+ to be used with any Pi model, or a Pi 2. and the updates to Raspbian will continue to be made with every Same Raspbian Raspberry Pi in mind. The Raspbian operating system is used across all Raspberry Pi models, so there shouldn’t be any confusion or need to learn new stuff when getting a new Pi. All the same software and such will also be available on newer hardware. Newer is better WHAT SHOULD I DO WITH MY OLD RASPBERRY PI? That being said, newer Raspberry Pi models (such as the 3B+ in Put it to work in the house this issue) have performance improvements over the previous If you fancy putting together a file server or finally versions. The extra power or creating a Kodi box or retro games console, now is connectivity options might help solve an issue you’d the time to do it since you have a spare Raspberry had in a project, or even just improve your Raspberry Pi. These projects are easy and quick to make, Pi desktop setup. and at least your old Pi will still be put to use. For business Zero to do If you use a Raspberry Pi in an enterprise setting, While the Raspberry Pi 3B+ is more powerful than a newer Pi models tend to have extra functions with Pi Zero, the Zero’s size makes it much more suitable business in mind, such as the Power over Ethernet for smaller projects, so don’t count it out yet. Keep (PoE) pins and PoE HAT coming to the Pi 3B+. Like your Pi Zero for projects that could use it over a any new bit of tech, it’s worth researching to see bigger and more powerful Pi. if it would aid your company. WILL MY PROJECTS WORK ON A NEW Give it to someone in need RASPBERRY PI? There are many organisations that could do with Backwards compatible more Raspberry Pi boards, whether it’s your local Jam or Code Club or even a school in need of Python code and Scratch programs will work just computers. They don’t always need the latest and fine when moved between Raspberry Pi models, greatest Pi, as tutorials will work fine across a broad range of different models.62 April 2018 raspberrypi.org/magpi

YOUR QUESTIONS ANSWERED F.A.Q.FROM THE RASPBERRY PI FAQRASPBERRYPI.ORG/HELPWHAT DO I GET WHEN I BUY ONE? is available to order online in the UK from our partners element14You get the Raspberry Pi board itself. A power supply and microSD (magpi.cc/qWBdNT) and RS Components (magpi.cc/wRQHGW),card are not included, but can be purchased at the same time for £99 + VAT, and from distributors and resellers around the world.from most places that sell the Raspberry Pi. You can also purchasepreloaded microSD cards; we recommend buying these from us or IS THERE A BUY-ONE-GIVE-ONE PROGRAMME?our licensed distributors rather than from third parties on eBay, as Not at the current time. We may implement a programme of thisour software is updated regularly and cards sold by third parties sort one day, but the scale of an undertaking like this is somethingcan quickly become outdated. our small team isn’t equipped to handle. You can, of course, simply buy an extra Raspberry Pi to donate to the person or organisation ofWHY IS THE PRICE IN US DOLLARS? YOU ARE A UK COMPANY! your choice.The components we buy are priced in dollars, and we negotiatemanufacturing in dollars. Because currency markets are so volatile, I WANT TO BE A RASPBERRY PI RESELLER.we price the final board in dollars as well so we don’t have to keep We have an exclusive manufacturing and distribution arrangementchanging the price. with RS and Farnell. Resellers buy the Raspberry Pi in bulk from them (which reduces shipping costs to nearly nothing) and sell on.CAN I BUY A RASPBERRY PI KIT? You do not need any special licence to resell, and the distributorsRaspberry Pi resellers produce some great bundles for people who are very happy to sell on to resellers. If you are interested in joiningwould rather get everything they need from one source. In 2016, our Approved Reseller programme, contact us by sending an emailwe put together our own Raspberry Pi Official Starter Kit. The kit to [email protected] THE HOTTESTNEW PRODUCTS FOR YOUR PITHE NEW PiCube PGiwTEriaTthff1tihc5i&s %cPoidCOeu:bFeF MAGPI2017PiTraffic PiCube is a 4x4x4 LED Cube perfect for both beginners and professionals toTake your first steps into strengthen their logic by typing complexinterfacing with the real world. code to draw out different patternsPiTraffic provides the building among its various uses.blocks to explore ideas and takelearning further. Just pop it on your FEATURESPi and start to learn coding. • Each Layer as well as each LEDFEATURES can be individually accessed and controlled as per requirements• Compatible with Raspberry Pi 3, 2, B+, • 64 high intensity A+, Zero, and Zero W monochromatic LED’s• Fully assembled • 40-pin stacking header for accessing GPIO of RPi• Easy Programming • Available in three vibrant colours• 40-pin female header included RED, GREEN, BLUE to boost height for Pi B+, 2, 3 • Comes un assembled and fully assembledwww.shop.sb-components.co.uk Call: 0203 514 0914At SB Components we strive to offer our customers the best prices for the best products. Our product team workstirelessly to source top quality affordable components from around the world. Raspberry Pi is a trademark of theRaspberry Pi Foundation. Raspberry Pi not included.

FeatureWOFELRCAOSMPEBTEORRTHYEPOILRYOMBPOICTSS2014 T he Raspberry Pi has helped revolutionise many things. From computing education,The obstacle course to the maker community, and even howfor the first Pi Wars you play games at home, the Raspberry Pi haswas much simpler had a huge impact. It’s also helped change the face of hobby robotics, making it more accessible than ever before. To celebrate this renaissance of robotics, the organisers of the regular CamJam event hold a yearly contest known as Pi Wars that pits the Raspberry Pi community’s best automated efforts against each other. There’s no fighting, though: the robots take part in devious challenges designed to test how well they’ve been built and programmed, and at the end of the day they get to be taken home in one piece! Most of the time. This year, over 70 teams are taking part over two days. Here’s what you can expect from the event.64 April 2018 raspberrypi.org/magpi

PI WARS 2018 FeatureTHE HISTORY OF PI WARSTHINGS HAVE CHANGED OVER THE YEARS. HERE’S WHAT HAPPENED AT THE LAST THREE PI WARSP i Wars is a spin-off from the Three Point Turn which was an 2017 SNFPOIIEGRWXNTTAUHRPES! CamJam – the Cambridge autonomous test of a robot’s Raspberry Jam. Now in ability to drive forward, make a A tense Pi Noon match at Registration for theits fourth year, the competition turn in the road, and then return to last year’s Pi Wars event next Pi Wars isn’thas grown in size and scope, as its starting position. open yet but whenchallenges and team categories PI WARS 2017 it is, you’ll find it onare added or updated so that the PI WARS 2015 piwars.org aroundcontestants can get a truly fair test For 2017, we decided to move the autumn time. Makeof their skills against their peers. The 2015 competition was also event to April to allow schools, in sure you apply early Michael Horne, CamJam and Pi held in December and we moved particular, more time to work on – registrations closeWars organiser, tells us a little bit venue, to the Cambridge Computer their robots and to avoid exams. before the eventabout the history of the event… Laboratory (William Gates We also decided to hold the event and you can’t just Building), to give us some more over two days, with schools taking turn up on the dayPI WARS 2014 space to work with. The courses centre stage on the first day and with a robot in hand! were much better presented – everyone else being divided intoThis competition, in December featuring actual paint! – and we three categories on the Sunday:2014, was our first, and was held at changed some of them to keep Beginners, Intermediates, andCamJam’s previous regular home things fresh. The challenges were: Advanced. We were welcomed backat the Institute of Astronomy. Obstacle Course (with different to the Cambridge Computer Lab andThe courses were a little low-tech obstacles and featuring the brand this was the busiest event yet with– unpainted hardboard, courses new turntable, designed and around 60 robot teams competing.on table tops, and a line-follower created by PiBorg), Skittles (knockcourse made out of paper taped the pins over with a ball), Pi Noon The challenges were once againtogether. It took place over just (robot vs robot balloon popping), revised: Straight Line Speed Testone day and we split robots based Straight Line Speed Test, Three (which was changed to a strictlyon cost – sub-£75 and over-£75 Point Turn, Line Follower, and autonomous event), the Minimal(not including the Raspberry Proximity Alert. This time, robots Maze (a new autonomous course),Pi). Challenges were as follows: were split between those under Line Following (which used theObstacle Course, Line Follower, A4 size and those between A4 and outline of our robot logo – muchProximity Alert (get as close as A3 size. This increased size gave to the dismay of many teams!), Pipossible to a wall), Robot Golf us some challenges as the courses Noon (which added another two(push a ball through a hole in a needed to allow for larger robots. balloons as targets to be popped),wall), Straight Line Speed Test, Obstacle Course (which doubled inSumo Battle, and the fiendish size from previous years), Skittles (this time, teams had to go and2015 ‘collect’ the ball to be rolled at the pins – a slight misstep on our part asThe obstacle course received it proved to be a very tricky physicala big update for 2015, including challenge!), and Slightly Derangedthe now famous turntable! Golf (in which a real golf ball had to be moved around a short course and through a windmill’s rotating sails at the end and into a hole).raspberrypi.org/magpi April 2018 65

FeatureAHOWRTOOBBUOILTDWANT TO ENTER PI WARS? YOU’LL NEED A ROBOT THEN…WHERE TO BUY GOOD GOPIGOROBOT PARTS STARTER KITS > $200 / £200MODMYPI If you want to learn how to magpi.cc/dYpiRj make robots, you need to start The GoPiGo 3 kit is a great starter formagpi.cc/HdcIvp at the beginning. Here are some people wanting to learn how to codeAs well as selling kits from PiBorg, great starter kits that you can and control robotics. With the baseone of the leading Raspberry Pi go on to expand into your own kit and a great set of tutorials, you’llrobotics makers, ModMyPi has other robo-competitor. quickly figure out the basics. Thekits and plenty of robot components. controller board lets you connect DIDDYBORG V2 extra sensors, allowing you to learnADAFRUIT and grow your robotics skills. > £210 / $290magpi.cc/skzElb magpi.cc/MokmEg CAMJAM EDUKIT 3America’s premier hobby electronics An expensive kitsupplier also has an amazing range but a very good > £18 / $25of robot parts and kits that it has one – PiBorg’s magpi.cc/tNKkmkdeveloped itself. DiddyBorg is a A great, classic starter kit, the powerful Raspberry Pi CamJam EduKit 3 comes with theDEXTER INDUSTRIES robot running on six wheels to basics for making a robot. You’ll make it extra sturdy. You’ll be need to add a Raspberry Pi anddexterindustries.com able to outrun all your opponents chassis – although you can alwaysDexter is a hobby robotics specialist, with it, and you can easily add use the box for the latter! It’s a verywith a number of kits and sensors sensors to make sure it can be simple robot, but it does teach theand such made specifically for fully autonomous. basics and has decent parts that youthe Raspberry Pi. You can buy its can use when building your robot.products from ModMyPi in the UK. YETIBORG V2 > £160 / $220 magpi.cc/TADbiy From the robot boffins at PiBorg, the new version of the YetiBorg is built to run on a Raspberry Pi Zero. It’s small, powerful, and extremely well put together, much like the other PiBorg offerings. The ZeroBorg motor controller it comes with lets you add standard analogue sensors, and can be daisy-chained too.66 April 2018 raspberrypi.org/magpi

BUILDING TIPS PI WARS 2018 FeatureTSYENPSEOS ROSF STLRITNAREVAEFIGOLHLITNLOLAWINEER RBROEUSBILOODUTINRCGESULTRASONICRANGE FINDING magpi.cc/ujFFZz WANT A HAND BUILDING A ROBOT? These sensors are great at following MAYBE THESE PLACES CAN HELPmagpi.cc/UJaTWJ a line drawn on the floor, by sensing the difference in shade betweenUltrasonic sensors use ultrasonic the two. Line-follower sensors are usually hidden under a robot andsound waves to measure distance. used for fun circuit challenges.They’re pretty popular amongrobot kits because not only dothey help teach you about sensorprogramming, they also looklike eyes.CSAEEMTEHREA WORLD INFRARED PIBORG FORUM ANOTHER RANGE FINDERmagpi.cc/28IjIsz magpi.cc/RmbMDYWith a bit of skill, and a lot of help magpi.cc/rVRhwP The PiBorg forum is a great place to ask aboutfrom the OpenCV software library, Depending on material, an infrared PiBorg kits. The team behind them are experts atyou can get a Raspberry Pi robot range finder can be more accurate robotics as well, so they should be able to help youto react to the world around it. It’s than an ultrasonic one. However, with any query.mainly used for differentiating they don’t work so well outdoors.colours, but OpenCV is very Luckily, Pi Wars is an indoor event!powerful and can do more. MSSEEICNNRSSOOITSRIVWSEITBCOHDY RASPBERRY PI FORUM magpi.cc/vywZnT raspberrypi.org/forums Some simple robot kits make use of The Raspberry Pi community are always happy microswitches to figure out when to help someone in need. Give the forum a search they’ve hit a wall. Classically, the first to see if any of your questions have already robot will then turn away from the been answered. wall, but you can always add one as a shut-off switch for a straight- OPRF ETVHIEOUMSAIGSPSIUES line speed test We’ve done robot tutorials in the past – including a guide on how to make and upgrade one in issues 51 and 52 respectively. magpi.cc/issuesraspberrypi.org/magpi April 2018 67

Feature HBUOILWD THWEIIRNRNOEBORTSS HERE ARE SOME OF THE TOP ROBOT TEAMS FROM PAST PI WARS – WHAT HELPED THEM WIN? TRACTORBOT One of the unique features of TractorBot was the interchangeable CONTEST: PI WARS 2014 noses for different contests – for WINNER: UNDER £75 example, for the golf game they BUILDER: IPSWICH MAKERSPACE used an extended nose that would keep the ball rolling ahead of the One of the first winners of Pi Wars, robot. Unfortunately, while good for the TractorBot was made out of keeping the ball under control, it did laser-cut wood and created by the not help to release the ball through folks at Ipswich Makerspace, who the hole. They were also able to add are veterans of the competition. pipe insulation for the sumo contest to soften impacts on the robot.REVENGE Pi Wars with the robot PyroBot, BRIAN’SOF PYROBOT which unfortunately did not place. ADVICE: However, he came back stronger inCONTEST: PI WARS 2015 2015 with the Revenge of PyroBot. Build your baseWINNER: LARGER THAN A4 early. Drive it atBUILDER: BRIAN CORTEIL “My robot Revenge wheel least a couple of layout was inspired by PiBorg hours, two daysBrian Corteil should be DiddyBorg kit layout,” said Brian.recognisable to readers of the mag “I built the chassis in a weekend a week.– he wrote our feature on building and was driving it on the Sundaya robot in The MagPi #51, which evening. The rest of the robot Evolution was built specifically forwas then further developed into was added over the following the A4 category, with the aim tothe Tiny 4WD. He entered the first months, with the final design put make a bigger and better robot than together on the Friday evening the original. The ability to swap before Pi Noon!” attachments was dropped because of the time involved (although one KEITH was created for Pi Noon). It was a EVOLUTION much sturdier beast, using more custom parts than before as well. CONTEST: PI WARS 2015 WINNER: A4 AND SMALLER “We tried to build a robot that BUILDER: ANDY & HARRY MERCKEL would be able to do well in all of the challenges,” the team wrote. KEITH Evolution is the second “Although there were many robot by the Merckel team, the compromises along the way!” aptly named evolution of their robot KEITH from the first Pi Wars. KEITH stands for Kinetic Electronic Interactive Tracked Hardware.68 April 2018 raspberrypi.org/magpi

PI WARS 2018 FeatureEXABOT – along with a lot of training to get to grips with some of the challengesCONTEST: PI WARS 2017 awaiting at Pi Wars.”WINNER: SCHOOLS AND KIDS CLUBSBUILDER: TEAM EXABOT While of course the robot build is very important, training and testing“Our team built a completely custom should not be overlooked. The ExaBotrobot for this year’s competition,” the team even went as far as buildingteam wrote on their blog. “Working their own maze to tweak theiron everything from the core electrical software at the last minute, findingand mechanical design to the Python some issues they were able to accountprogram used to operate the robot for before the big day. Still, issues were found during the challenges, so you can’t account for everything. MR BIT with he and Rebelle learning as they went. Simpler solutions were CONTEST: PI WARS 2017 found in favour of going over the WINNER: BEGINNERS top, including one involving the BUILDER: BROUGHTON FAMILY use of multiple distance sensors for the maze, and a simple claw/ Tom Broughton and his daughter mandible design controlled by Rebelle had never built a robot before, motors for manipulating the ball but that wasn’t going to stop them in the golf challenge. from entering Pi Wars – after all, it did now have a Beginners category. “Very naively we assumed it You can follow the very careful would be a very simple task to put progress of building the robot on a robot together,” Tom admitted. Tom’s blog (digitalpolymath.co.uk), “But we soon realised, as mentioned in many of our posts, what a huge underestimation this was.”STEVE months before the April 2017 CPIAWTEAGROSRIES Pi Wars event, going throughCONTEST: PI WARS 2017 different controllers as the robotWINNER: INTERMEDIATE was built and tested. In the end,BUILDER: TEAM STEVE Steve ended up being a modest robot, running off a Raspberry PiSteve is not a fancy acronym (or Zero and an Arduino, and using abackronym?) like KEITH, but is Dagu chassis and speed controller.instead just a robot called Steve. Despite this, it managed to win theA robot that looks like a dog. Intermediate category and evenSteve had been in the works for came first in the golf challenge. Good boy, Steve! MAX exception, especially compared to PI WARS 2014 the balancing two-wheel robot he CONTEST: PI WARS 2017 had originally planned for the 2017 > Under £75 WINNER: ADVANCED/PRO competition (hence the team name). > Over £75 BUILDER: 2 WHEELS OR Compared to the Tiny and the PI WARS 2015 NOT 2 WHEELS Tiny 4WD, Max has an additional series of distance and line sensors > Larger than A4 Brian Corteil came back to Pi Wars and a more custom chassis. While > A4 and smaller last year with another winner in it didn’t do particularly well in the Max, based on the Tiny robot that automated events, Brian’s tactic PI WARS 2017 was originally built for The MagPi! of practising his robot control paid Brian is great at building powerful, off, with him placing highly in (and > Schools and Kids sturdy robots and Max is no even winning two of) the manual- > Clubs control events. > Beginners > Intermediates > Advanced/Proraspberrypi.org/magpi April 2018 69

FeatureTHHOEWCTHOACLLOENNQGUEESRTHE EVENTS AT PI WARS TEST THE BUILD QUALITY AND PROGRAMMING SKILL BEHIND EACH ROBOT.CO-ORGANISER MICHAEL HORNE REVEALS THE TASKS THEY NEED TO CONQUERAUTONOMOUS CHALLENGES THE MINIMAL MAZESTRAIGHT-LINE SPEED TEST ROBOTS NEED TO AUTONOMOUSLYHOW FAST CAN YOUR ROBOT GO IN A STRAIGHT LINE? NAVIGATE A SIMPLE MAZEA shallow trough 7.3 m (24 feet) together. While it seems like it will Don’t let this simple-looking maze fool you: thislong comprises the course for the be simple, any robot maker knows can be quite tricky for robots as you’re not allowedspeed test. Your robot needs to that very few robots go in a straight to help them, and they’re not permitted to touchtraverse this course autonomously line without some coding help. any walls.as fast as possible, without hittingthe sides. The course is usually OFFICIAL TIP: It’s important The concept behind this maze is for your robot to534 mm wide, but there are sense the different colours that are painted on thesections where it will narrow. to get a balance between being wall to inform how it navigates. Programming your as fast as possible and being robot to turn while seeing certain colours, and only With a white line down the centre as accurate as possible – we’ve moving so much at a time, is key to navigating thewhich you can use for navigation, added chicanes which count maze successfully. While slow and steady can winthe course will be run three times as ‘walls’ which incur penalties the race, the event isand the scores for each run added when touched. measured on completion time, so don’t dawdle.SOMEWHERE OVER THE RAINBOW OFFICIAL TIP:YOUR ROBOT NEEDS TO FIND AND TOUCH A SERIES There are so manyOF COLOURED BALLS, PREFERABLY IN SEQUENCE ways to do this, but we’ve allowed theRobots are placed at the centre of a by 122 cm, and the black walls addition of ‘markers’ onsquare arena in this new challenge. are 300 mm high. At each corner the course which mightThe wooden arena measures 122 cm there’s a coloured ball suspended be an easy way to 100 mm off the floor of the box. orientate yourself if you Your robot must visit each ball use ‘vision’ to navigate. once, and they can do that in any order, or shoot for more points and a maximum of three attempts, go in the predetermined order of with their fastest attempt used Red, Blue, Yellow, and Green. for scoring. The kicker? Each ball’s OFFICIAL TIP: We’re supplying placement will be random for each team, so the robot truly has to look a calibration or ‘try out’ course in for the correct colour. Contestants addition to the ‘real’ course – use have seven minutes to perform it to get your sensors in shape before the real runs.70 April 2018 raspberrypi.org/magpi

PI WARS 2018 FeatureCREHMOATLE-LCOENNTRGOLELESD PI NOON BURST YOUR OPPONENT’S BALLOONS USING SUPERIOR MOBILITY AND TACTICSDSLEIRGAHNTGLEYD GOLF An audience-favourite challenge the day, in the past there have been WOTOTAHWYESIRN that somewhat resembles the ramps, marbles, sharks, and The BigYOUR ROBOT MUST PUSH battle mode from Mario Kart. Each Whirling Circle™ to contend with. While completingA GOLF BALL THROUGH robot is equipped with a series of Contestants need to figure out the challenges is theA DEVIOUS COURSE TO tiny balloons, along with a needle. best way to tackle each obstacle, and main way to gainTHE HOLE The aim is to pop your opponent’s hopefully prepare their robot for points, robots will balloons with your needle, and not any eventuality. You only get one also be judged onThink mini golf in this excellent have your own popped. attempt, and you’ll be judged on other aspects…challenge that showcases your how fast you complete the course.robot’s dexterity and your team’s Each duel lasts three minutes. Although don’t just try to charge BLOGGINGability to precisely control it. A real There are many rules, such as through obstacles.golf ball must be pushed around a ‘don’t spin’ and ‘don’t purposefully Keeping a log ofgolf course, avoiding obstacles, and damage the opponent’, which are OFFICIAL TIP: Without giving too how you built thedropped into the hole at the end. mainly in place to reinforce that robot, with added this is supposed to be a fun event much away, make sure you can get photos and video, You can’t carry the ball, and the that you shouldn’t try and game out of tight spots, maintain control, can help you winball is only allowed to leave the by being silly. Remember, judges’ and practise slow turns. Grippy extra points.surface of the course if the team/ decisions are final. wheels will help this year, too.robot decides to chip the ball. TECHNICALOtherwise, pushing and hitting the OFFICIAL TIP: Practise remote- THE DUCK SHOOT MERITball is the way to go. Teams can’t becheeky and ‘capture’ the ball with controlling your robot as much TARGET SHOOTING Your robot goesthe robot either. The total time after as possible, as control is vital in WITH ROBOTS! before the trainedthree runs will be used in scoring. this challenge. eyes of engineers Robots will be placed in front of the to ascertain the OFFICIAL TIP: We’ve lowered THE OBSTACLE COURSE targets, and will not be allowed to quality of your Pi- cross a boundary line that is at least a powered machine. the tee this year, so it should NAVIGATE AN OBSTACLE metre away from the targets. Several be easier, but get control of the COURSE IN THE FASTEST TIME targets will be presented between 10 ARTISTIC ball early! and 15 cm in height, held at different MERIT The obstacle course is a lot of fun… elevations, and not all at the same to watch. Robots regularly get a bit distance from the boundary. Does your robot stuck and teams usually get a bit look cooler than frustrated, which makes for great Robots can either use five supplied a T. Rex surfing drama. It should be televised really. balls to knock down the targets, or while wearing use a pre-installed cannon that fires sunglasses? Then While the exact layout of the up to five soft projectiles (such as it will win some obstacle course is a mystery until Nerf darts). Any method of aiming extra points. is allowed (including laser pointer). Contestants have five minutes to make three attempts, and points will be tallied up depending on how many targets are hit. OFFICIAL TIP: You only have five shots, so be as accurate as possible and take your time to line up.raspberrypi.org/magpi April 2018 71

Tutorial WALKTHROUGH72 April 2018 raspberrypi.org/magpi

THE Official £12.99Tutorial 200 pages of Raspberry Pi RASPBERRY PIPROJECTS BOOKAmazing hacking and making projects from the makers of magazine Inside: How to get started coding on Raspberry Pi The most inspirational community projects Essential tutorials, guides, and ideas Expert reviews and buying adviceAvaniolwable magpi.cc/store plus all good newsagents and:raspberrypi.org/magpi April 2018 73

Review MATRIX VOICE matrix.one From £40 / $55MATRIXVOICEA voice-recognition board featuring an LED loop andeight-mic array. Phil King has a few words with it M easuring 3.14 inches a Xilinx XC6SLX9 Spartan 6 FPGA (8 cm) in diameter, this (field-programmable gate array), whose 9152 logic cells offer scope circular add-on should, in for customisation if you know how. mathematical terms at least, prove ESP or not a perfect fit for the Raspberry Pi. A Two versions of the Voice are available: standard and ESP32 with GPIO header extender enables it to built-in WiFi and Bluetooth. While the former relies on connection to a clear the Pi 3’s USB ports, but will Raspberry Pi, the latter (costing an extra $10) can be programmed on a also work with any newer 40-pin Pi before being set free to function as a standalone device. The most model, including the Pi Zero. It visually impressive aspect of the Voice is its circular ‘Everloop’ array looks good mounted on top, a blue of 18 RGBW LEDs. As well as the LED on its underside illuminatingRelated the Raspberry Pi board below. unable to use it to access the RaspberryAIY In essence, the Matrix Voice Pi’s GPIO pins directly.VOICE KIT is a slimmed-down spin-off of Many voices Google’s cardboard Matrix’s original Creator board. One of the key plus points of the kit for voice Voice is its compatibility with recognition Whereas the Creator was crammed a wide range of voice assistant includes a platforms, including Amazon mini speaker with all sorts of sensors, and Alexa, Google Assistant, and and two-mic PocketSphinx. Disappointingly, array, while Compatible with a wide range of however, getting started with the its Voice HAT voice assistants, including Alexa device is made more difficult by board features and Google Assistant the lack of helpful, Voice-specific connections information on the matrix.one for servos other bells and whistles, the Voice ability to display cool light patterns, website. A lot of the documentation and motors. focuses on voice recognition. To this can provide useful visual and examples are related to the this end, it retains the array of feedback during voice interactions. Matrix Creator, and the Voice data £25 / $25 eight digital MEMS MP34DB02 sheet only offered links to a couple microphones, although here Near the middle of the board, as of tutorials. Matrix tells us it ismagpi.cc/AWeXwv they’re arranged differently: seven on the Creator, is a square hole for working on creating additional ones placed at regular intervals around mounting a Camera Module if you and improving the documentation. the perimeter and an eighth in wish. Elsewhere, a 24-pin female the middle. Audio processing – expansion header is connected to Following the Alexa step-by-step including noise cancellation and the FPGA to connect and control guide (magpi.cc/Wzovwo) took de-reverberation – is handled by electronic components, but (testing it with a basic LED circuit) we were74 April 2018 raspberrypi.org/magpi

MATRIX VOICE Review Left The top of the MSaakyers Voice features a ring of 18 RGBW A LEDs and eight complete, affordable, mini microphones and user- friendly tool for simple to complex IoT voice app creation Matrixover two hours, including lengthy Exploring Matrix’s GitHub repo, While the Matrix Voice is clearlyMatrix software installation and we discovered a PocketSphinx a capable piece of hardware, untilsetting up a developer account with example (magpi.cc/qlRbbH) to the documentation improves it’llAmazon. We had problems getting show LED patterns triggered be hard to make the most of it.it to capture our voice at first, but by speaking various phrases.upon reinstalling to a fresh Raspbian Examining the demo code (written, Last wordStretch image it worked well. The like the other examples, in C++)mic array was able to pick up our gave us an insight into how to listen The Matrix Voice hardware is polished, capable,“Alexa” wake-word even from the for keywords and trigger the LEDs. and versatile, but the lack of specific productfar side of the room, the LED loop support on the Creator-focused website currentlyglowing green as Alexa then listened Of the few other code examples makes it difficult for users to get started. While theto our enquiries and commands. For compatible with the Voice, we Voice’s spec is superior, its price is also higher thansound output to a speaker, for some found one for sensing the direction some simpler rivals, such as the Seeed ReSpeakerreason we were advised to use the of sounds using the eight mics. 4-Mic Array (£23) and Joy-IT Talking Pi (£31), whichRaspberry Pi’s 3.5 mm jack rather While possibly useful for a project, may well be sufficient for many home projects.than the one on the Voice. the demo code (for the Creator) would need altering to suit the Voice’s different mic array layout.raspberrypi.org/magpi April 2018 75

Review MAKE MARK APP BETA makemarkapp.comMSaakyers FREE Files ondemand foreveryoneMake Mark App MAKE MARK APP BETA Rob Zwetsloot investigates a different way of linking Dropbox to Raspberry Pi using middlewareRelated D ropbox has never been very creating folders on the Raspberry on making it better. Instructions well supported in Linux. Pi, setting up folders on Dropbox, and documentation are providedTCHLAESSIC Raspbian has it even worse and making it launch at boot. You in somewhat broken English,DROPBOX than standard flavours of Linux. In can then log in to Make Mark from although they’re easy enough toSETUP the past, getting Dropbox to sync the website and manage your files. understand to get you started. to a Raspberry Pi has required some Want to use the custom coding, but Make Mark App Still in beta, the software While it’s not the full auto- usual Dropbox makes the process a bit easier. currently only supports PDFs and syncing solution we’d been hoping syncing method e-book files. The system truly acts for, it does work well as a middle for Raspberry step for transferring files between Pi? Check out Works well as a middle step for the Raspberry Pi and Dropbox. We our tutorial transferring files between the look forward to seeing it become straight from Raspberry Pi and Dropbox easier to install and support more issue 48 of files in the future. The MagPi. It’s still a little DIY: you need to as middleware – it will list what files set up Make Mark as an app in the you can upload from your Raspberry Last wordmagpi.cc/2c9NnPC developer section of your Dropbox Pi and then has you manually do so. account and get an app token. With They’ll then show up in Dropbox in It’s definitely a beta, but shows that, you can download a script the Make Mark App folder. great promise for a future that will set up everything you need middleware app for Raspberry to install the app. This includes We had a little trouble with Pi and Dropbox. setup, but the developer is working76 April 2018 raspberrypi.org/magpi

Tutorial STEP BY STEP SUBSCRIBE AND UP S3A5V%ETO on the cover priceOUT NOWISSUE #05 hsmag.cc78 March 2015 raspberrypi.org/magpi



NES CASE Reviewmagpi.cc/PDIDML£15 / $20 MSaakyers NES case specifically designed for Raspberry Pi 3, 2, and B+ Kintaro NES CASE Rob Zwetsloot plays with power as he turns his Raspberry Pi into a mini NES with the Kintaro Entertainment System C ases for the Raspberry Pi the halves together from below. system. However, even with the are a dime a dozen these Job’s a good ’un. ‘vents’ on the side of the case, days, so it’s nice to see accessing the GPIO pins is tricky, people selling fun themed cases Flip the flap and putting a camera cable through for your Pi projects. It sets them the USB flap isn’t ideal. While the apart from the myriad plastic, While on the original NES the case was not designed with this in yet functional, cases for the controller ports were located on mind, it’s worth mentioning in the Raspberry Pi. the front of the machine, the USB event that you were planning to The maker of this case, Kintaro, ports on the Raspberry Pi aren’t use this as your only case. sells a couple of retro-console- quite arranged like that. In a rather themed cases. Along with thisRelated NES-inspired case, you can also Useful for using a Raspberry Pi get a (US purple) SNES-style as a standard computerOFFICIAL case. The NES one is smaller and or a retro gaming systemRASPBERRY simpler than the SNES version,PI CASE but still functions as a proper ingenious move by Kintaro, the Last word Raspberry Pi case. cartridge flap has been recreatedA more versatile Putting a Raspberry Pi in the on this case – simply flip it up to A great, simple case that mightcase. While it case couldn’t be easier – the two gain access to all the USB ports and be good for your home mediadoes look cool, halves come unfastened in the the Ethernet port. Otherwise, all setup if you’re missing theit may not quite box so you can separate the two. the important ports and slots are elusive NES Classic Mini. Don’tbe NES cool. Inside you’ll find four screws and a accessible while the Raspberry Pi is get it for hacky electronics couple of heat sinks in bags which in the case, even the microSD slot. projects, though. £6 / $10 you’ll need to remove. Place the Raspberry Pi inside the bottom The case is really useful formagpi.cc/ppUaBN half, replace the top half, and then using a Raspberry Pi as a standard use the provided screws to secure computer or a retro gamingraspberrypi.org/magpi April 2018 79

Review BOOKS RASPBERRY PI CRACKING CODES working up to more advanced BESTSELLERS Python topics. Python’s strengths WITH PYTHON MANGA MATHEMATICS at data handling make this Author: Al Sweigart sort of thing fairly painless, No Starch’s Manga guides use manga Publisher: No Starch and (relatively) few external storytelling to make difficult subjects Price: £25.50 libraries are needed, so the surprisingly approachable ISBN: 978-1593278229 beginner can stay fairly focused magpi.cc/WiQljD on learning coding, not stacking THE MANGA GUIDE together modules. TO LINEAR ALGEBRA Yes! A book that Complete code listings are teaches Python given early in each cipher sample, Authors: Shin Takahashi programming without growing longer with each chapter & Iroha Inoue games, but is still full of fun, – these are well commented, intrigue, and playfulness. Along and slowly broken down and Publisher: No Starch the way you’ll also learn a lot about examined, so the beginner need Price: £19.99 ciphers, encryption, and hacking not feel too intimidated. Learning ISBN: 978-1593274139 – although little of the book deals from working through longer magpi.cc/NGUfyX with modern ciphers that are listings is reminiscent of the secure against the computational 1980s, when magazines for the We all reach a stumbling point power that can be wielded against classic 8-bit computers carried somewhere when learning maths. them, by working through long programs to type in. But If linear algebra is yours, Takahashi’s centuries old ciphers you’ll learn never mind the nostalgia, it’s a narrative-driven breakdown of many of the principles behind great way to learn – especially the subject into small chunks and today’s encryption. for adults and teens who aren’t essential diversions will make gripped by game coding. several difficult concepts suddenly You’ll also learn a lot of easy to understand. programming techniques, and Score the practical nuts and bolts of TTOHECMALACNUGLAUSGUIDE programming, from handling text, through loops, to functions, then Authors: Hiroyuki Kojima & Shin Togami CLEAN C++ not just a restatement of best practices laid down in many Publisher: No Starch Author: Stephan Roth Java books, but as it goes from Price: £15.99 Publisher: Apress the general to the specific, the ISBN: 978-1593271947 Price: £29.99 many C++ examples illustrate magpi.cc/moKUBC ISBN: 978-1484227923 how relatively simple (and magpi.cc/LlKCOy A lovely attempt at tying calculus ultimately beneficial) it is into its real-world applications, C++ projects seem to incorporate the practices from an economist with a strong more prone than into your own code. Roth is an appreciation of the subject. most to delivering opinionated commentator – but Perhaps best used in tandem “fast and highly optimised generally in a good way – and with a dryer and deeper textbook [code], with a cruel syntax and a knowledgable and passionate or MOOC, but it will make either ignoring elementary principles proponent of best practices. much clearer. for good design and well- “Lots of C++ code that is written written code.” Roth brings all today looks like it was written in TRHEEGRMEASNSGIOANGAUNIDAELYTOSIS the best ideas of the Clean Code the 1980s,” says the blurb on the movement (clean code is easily back of the book. All too true, sadly Authors: Shin Takahashi understood and maintained, it’s – but follow most of Roth’s advice & Iroha Inoue not about ‘beautiful code’), and and you’ll find that clean coding the possibilities of this decade’s is not incompatible with C++. Publisher: No Starch improvements to the language. Everyone who has to work on your Price: £19.99 codebase – including the future ISBN: 978-1593277284 Clean C++ delivers sound advice you – will be grateful. magpi.cc/KobuGE on testing; design principles (and software craftsmanship); Score A well-chosen subject for a clean code; object orientation; manga guide. If the level is and design patterns. This is not always perfectly judged, the overall result is still a fair raspberrypi.org/magpi understanding, with illustrated analogies often helping to clarify difficult concepts. Again, a good companion to more traditional learning.80 April 2018

BOOKS ReviewPRACTICAL PYTHON Chapter one alone, containing ESSENTIAL READING: advice on the above, would rapidlyDESIGN PATTERNS pay for the book’s purchase by SCRATCHAuthor: Wessel Badenhorst the improvements it will The fun and easy way to start kids coding,Publisher: Apress foster if the reader follows a visual language more powerful than it seems.Price: £27.99 through with it – but theISBN: 978-1484226797 rest of the book deals Scratch Websitemagpi.cc/dVkzoo concretely with design patterns, and Pythonic Author: MITBadenhorst’s mission implementations of many Publisher: MITis simply to make you of the most useful. Price: Free downloada better programmer. To The chapters introduce magpi.cc/sjNTTSpromote thinking at a higher level a topic, and usually jumpof abstraction, this book teaches straight to a useful code snippet Naturally, the Scratch website hasDesign Patterns – something that – such as implementing part of a plenty of resources to start your kidshas become popular in particular real-time strategy game for the learning, from free PDF guides toin object-oriented languages prototype pattern chapter – before Scratch Cards.from Java to Ruby. Beyond that, outlining the problem to be solvedthe author is keen for readers to by the pattern, then taking the Super Scratchemulate the practices of the best reader down whichever path best Programming Adventure!at the programming art, from advances understanding. As dodeliberate practice and single the ‘parting shots’, and a series Author: The LEAD Projectfocus, through systems thinking, of exercises, at the end of each Publisher: No Starchto mastering tools, and looking at chapter. A good and useful read. Price: £19.99other frameworks, languages, and ISBN: 978-1593275310paradigms to see what there is to Score magpi.cc/kmwfvibe learned. For confident younger learners, thisPRODUCT deliverables, but in terms of your concise, comic-style introductionROADMAPS organisation’s values, and where provides a quick introduction, and letsRELAUNCHED you want to make life better for your kids make some great games. your customers?Authors: C. Todd Lombardo, Scratch for Kids for DummiesBruce McCarthy, Evan Ryan, If this all sounds a little vague,& Michael Connors good. A roadmap is a Author: Derek BreenPublisher: O’Reilly strategic document, Publisher: WileyPrice: £27.99 not a product plan. Price: £21.99ISBN: 978-1491971727 To make it more ISBN: 978-1119014874magpi.cc/AKZhOp concrete, the book magpi.cc/TCyZow moves from the whyWhat is a product roadmap? An to the how – to make Not in any way dumbed down – aout-of-date listing of deliverables? a flexible roadmap brilliant guide to sprites, animations,A best-fit compromise that comics, programming, and plenty ofdoesn’t really satisfy any of your that can be shared games. And really good fun.stakeholders? A source of contention with your customers, withoutwithin your organisation? A bright promising anything that would Learn to Program with Scratchshiny vision of the future that your skew the product away from wherecustomers don’t trust? Roadmaps it should be going. This product Author: Majed Marjihave failed to keep up with agile we talk of could be an IoT project, Publisher: No Starchdevelopment, and are often mired in app, or website – but the advice Price: £27.99detail best put in a project plan. carries over into many other ISBN: 978-1593275433 fields. A thoughtful and thought- magpi.cc/KjPpaU Product Roadmaps Relaunched takes provoking re-examination of onea fresh look, removing focus from of the fundamentals of building a Truly excellent introduction to moredeliverables, and looking at the why. successful IT company. formal programming concepts,Where’s the product going – not in using Scratch, for beginners orset-in-stone phases of promised Score experienced Scratchers. Cool Scratch Projects in easy steps Author: Sean McManus Publisher: In Easy Steps Price: £10.99 ISBN: 978-1840787146 magpi.cc/2me3yQu Magic Mirror, 3D effects, using the Raspberry Pi’s Camera Module – there’s plenty here for any Scratch learner to move onto as the next step.raspberrypi.org/magpi April 2018 81





Community INTERVIEWMAKING MUSIC WITH ARASPBERRY PIThe album RPi ZWEI was created using just a Raspberry Pi 2 Yerzmyey In general you can find all kinds The entire idea of the project was of electronic music, although every to use only Pi 2 and nothing else. I Occupation: Musician song is different: from electro/ composed this music on the Pi and techno-pop, through Eurodance, then recorded it all directly from the M aking music on a Raspberry to instrumental electronica [a bit headphone output of the board. Pi is simple enough thanks like] Mike Oldfield. It then ends in a chiptune style with BitPusher2600’s The Pi 2 is powerful so the to Sonic Pi. However, remix made on the Pi. songs can be complicated and use multichannel, which makes for a demoscene musician Yerzmyey Why a Raspberry Pi? great tune for the listener. The most I bought one when the Pi 2 was complex song on the album consists decided to go one step further and still the new model. However, my of 26 independent channels of digi- decision back then was motivated music. The Pi can surely manage make an entire album using the directly by the announcement that more, but that wasn’t the point of the Raspberry Pi outsold the ZX this album. Raspberry Pi as his instrument. You Spectrum. I thought, “Aha! I have to get one NOW!” The Raspberry How did you go about composing can listen to RPi ZWEI here while Pi, being a British computer, is the album? important to me as I’ve been a I programmed all notes one-by- ZX Spectrum fan and user since one, as is customary on the music the eighties. trackers. You have to put all the notes/sounds in manually without The Pi is a modern, and potent, any automatic help. Otherwise I machine. Obviously, it’s not old use loops, but only when it comes school, but you can feel some cool to drum ‘n’ bass music (drum loops old-school philosophy behind it. are indispensable there) or when I you read through our interview with him: magpi.cc/WhekCf. Tell us about your album! What Above Yerzmyey has played music all over the world – including Japan kind of music would you say it is? Typical demoscene music is usually divided in two basic types: chiptunes and modules. Generally we might say that chiptune music is usually synthetic and full modules – like MOD, S3M, XM, etc. – are sample-based. The songs on my Raspberry Pi album are modules – the XM modules to be exact – made with a Raspberry Pi 2 and MilkyTracker working on the regular Raspbian system.84 April 2018 raspberrypi.org/magpi

YERZMYEY Communityplay the guitar (or ask some friends 1-bit music on ‘Wham! The Music Above Made on mention it’s much cheaper, smaller,to do it for me; I’m not a very good Box’ and after that I changed to a Pi 2, the RPi cuter, and far more portable).guitarist). I cut these recorded SoundTracker 1.1 and the AY chip. ZWEI mini albumguitars into loops and put them features five tracks Text editing, spreadsheets,into the song/module in a form of Since then I’ve made music internet with YouTube included,WAV files. Of course, the multilayer for over 60 games, mostly for ZX music listening, watching movies,technique is useful there too, so Spectrum; sometimes with such and stuff like that. I also do a lot ofI can ‘play simultaneously’ on distinguished ZX game-developers gaming, mostly using RetroPie.many guitars. like Jonathan Cauldwell – and many other, equally talented friends. I have my PC and the Pi My weapon of choice on the permanently connected into oneRaspberry Pi is MilkyTracker, a I participated in making numerous switchable monitor so I don’t havefamiliar and powerful tool. Of course demos for Spectrum and Atari ST – to buy a second PC, as the Pi isthe Pi can do a lot, so for example and played many chiptune concerts totally enough. Ten years ago thisone can use emulators or cross- in various places on planet Earth. was unthinkable. They weren’tplatform trackers to make chiptune called towers for nothing.music too. I tested how the SID chip How long have you beenemulation works on the Pi 2, with making music? Do you plan on making more musicthe GoatTracker, and it is really I remember making songs for our with Raspberry Pi?nice: magpi.cc/lrJKai. group’s first demos and games Actually I do. Of course, every time I in 1987 – games like Ghost Eater try to make some new stuff, so this There’s other software of course; (1987) andHunting (1988) – but I time I was considering buying andfor instance, there is Unreal Speccy don’t think they exist any more using the Raspberry Pi Zero for aEmulator for ZX/AY lovers and so (everything was recorded on tapes change. A smaller machine, moreon. There’s also really complex in those days) so the earliest demo limited – it might be interesting. Isoftware-synthesizers that you can I still have containing my chiptune will try, presumably.use – you can find out more info attempts comes from 1989 and myabout them here: magpi.cc/YUXfeE. first game music (a text adventure) Another thing would be to make comes from 1993. something for the Pi 3, but it’s soDo you have a background in powerful that probably I would havechiptune music? Have you used the Raspberry Pi for to make – I don’t know – someFor chiptune stuff I mostly use a ZX anything else? symphonic music on it? WhichSpectrum 48K with AY-interface, Like I mentioned before, the Pi is might be tricky because last timealthough when I started in the late a powerful machine so I use it for I tried that was in the ‘90s. Also,eighties, there was only BEEPER literally everything. It’s as useful as trackers aren’t very good for thisaccessible, so initially I was making any other modern computer (not to particular kind of music (MIDI is better here). But we will see. Or hear.raspberrypi.org/magpi April 2018 85

Community FEATURETHE MONTH INRASPBERRY PI Everything else that happened this month in the world of Raspberry PiBIG BIRTHDAYWEEKEND! OVER 100 JAMS CELEBRATED RASPBERRY PI’S SIXTH BIRTHDAY! C elebrations for the Raspberry Pi’s birthday have been getting bigger every year, and this year was the biggest yet! Over 100 Jams around the world organised a special event to honour the Raspberry Pi on its sixth birthday, and even despite the snow in the UK, the world was abuzz with Pi love. Edinburg, TX, USA This South Texas Jam couldn’t escape the fun of the photo booth either Irvine, CA, USA This Irvine Jam looked huge, with people showing off their amazing Raspberry Pi creations86 April 2018 raspberrypi.org/magpi

Cotswold Jam CommunityThis impressive beast was edible, and 60 cm long!Lagos, Nigeria Raleigh, NC, USAWhile fun, some serious learning We saw many cakes coming from Pi parties; this amazingwent down at the party Jams cupcake delicacy hailed straight from North CarolinaTokyo, Japan Southend, UKThe photo booth project This one was a bit closer to home as youngmade for Pi parties was a makers got to grips with the Sense HAThuge hit around the world!SNOWED IN!Unfortunately, a few Jams had to be postponed dueto the ridiculous snow the UK experienced in March.Many Jams will be rescheduling though, so keep aneye on your email and social media feeds! India Hacking about with Raspberry Pis under a very fetching blue light in Indiaraspberrypi.org/magpi April 2018 87

Community FEATURERASPBERRY PI 3B+IS HERE! The community reacts to the latest version of the Raspberry PiA new Raspberry Pi is always cause for a mini- celebration, even if we’ve just celebrated a Want to learn birthday! Launched on Pi Day (14 March or, in more aboutAmerican notation, 3/14) the Raspberry Pi 3B+ is the the Pi 3B+?ultimate version of Raspberry Pi 3. Here are some ofthe reactions from the community to the news… Check out our launch video: magpi.cc/GqePcNSelf-expression can take many forms, Alex Eames of RasPi.TV always updatesincluding excellent Raspberry Pi nail art. his ‘Pi family’ image whenever a newThe glittery green nail polish is also impressive model is released. It now includes Brazilian and Japanese Pi boards, too!FOR YOUR VIEWING PLEASUREHere are some great videos about the new Raspberry Pi! magpi.cc/ifxRwR magpi.cc/XzjWXI magpi.cc/msQxvmNEW RASPBERRY PI 3B+ RASPBERRY PI 3 MODEL B+ INTRODUCING THE RASPBERRY PI 3 MODEL B+REVIEW AND SPEED TESTS Here’s a gorgeous little stop-motion Eben Upton talks to Roger Thornton, Principal Hardware Engineer,Estefannie takes us through the animation to herald the arrival of about what’s new with the Pi 3B+ in this very informative video.differences between the original Raspberry the wee wonder, directed by TomPi 3 and the 3B+, including networking and Sutherland and friends, as a teaser forprocessing speed. It’s also a mad video. the release.88 April 2018 raspberrypi.org/magpi

THIS MONTH IN PI CommunityKICKSTART THIS!Raspberry Pi projects you can crowdfund this month BEST OF THE REST Here are some other great things we saw this monthRASPBERRY BOOM KITCHEN INFOBOARD magpi.cc/bkCCdB Infoboards seem to be theRemember the Raspberry Shake? Well, the team new hotness over on thebehind the seismograph HAT for the Pi are now Raspberry Pi subreddit –crowdfunding a new citizen science add-on with the sort of like a magic mirrorRaspberry Boom. The Boom detects low-frequency but without the mirror part.sounds that the human ear cannot hear, and a A screen you can checknetwork of these can help detect and pinpoint a huge at any time for info. Thisnumber of terrestrial and extra-terrestrial phenomena version we quite like as itthat would otherwise go unnoticed. doubles as an automated, voice-controlled kitchen assistant. Handy! imgur.com/a/pWrXl PARTICLE GENERATOR Unfortunately, the image here doesn’t do it justice – this series of 32×32 RGB LED panels creates a truly stunning particle generation effect. We can see this being repurposed for holiday decorations as well. magpi.cc/QZTsoxPHIASCWKAITBCLHE HRAATSPBERRY CASSETTE GAMES kck.st/2FHoNmk CONSOLENanomesher is back to crowdfunding with a new Following the trend ofSwitch HAT, improving on the design of the original putting a Raspberry Pithat we liked so much. It fixes one of our biggest in something a bit retro,concerns with it, the use of jumper cables to connect here’s a cassette tape witheverything. There’s also additional remote support so a Pi Zero inside. It’s beingyou can use it with Kodi – this is probably going to be a used as a games console.bit of a game-changer! We especially love the marker pen on the label to give it that authentic mix‑tape feel. magpi.cc/vxhcQyraspberrypi.org/magpi April 2018 89

Community COMMUNITY PROFILE COMMUNITY PROFILE AMANDA HAUGHS Meet Amanda, US-based teacher, Raspberry Pi Certified Educator, and maker of things Amanda A manda Haughs works as Lesson Resources, and fun projects the Digital Innovation at home, she’s on the right track to Category: Educator teacher on special be making a big difference, both in Day job: Digital Innovation ToSA assignment (ToSA) for Campbell her district and across the USA. Website: twitter.com/mshaughs Union School District in San Jose, California. Within the role, she Amanda took part in the second magpi.cc/hGVavU works to support teachers in Picademy cohort to run in North engaging their students, exploring America. Picademy, the two- Below Amanda works how to create “meaningful day training course run by the as teacher on special and relevant cross-curricular Raspberry Pi Foundation, provides assignment within her learning experiences.” free professional development school district to support for educators, both in the UK educators in broadening On her website, Amanda and North America. A week after describes herself as “passionate the event, as Amanda recounted computer-science about the integration of technology her experience on her blog, she skills through cross- and computer science education in was quick to admit that her head curricular experiences elementary classrooms to support was “still spinning with all the the development of creativity, Raspberry Pi goodness” she was Below right Amanda joined critical thinking, and problem- able to obtain over the weekend, Raspberry Pi Foundation solving skills in students.” And and she has since gone on to help staff members Carrie with her continued efforts to create in further sessions of the training Anne Philbin and James content such as her STEAM and CS across the country. Robinson, alongside fellow Picademy alumnus Nicholas Provenzano, on the Digital Making with Raspberry Pi panel at ISTE 201790 April 2018 raspberrypi.org/magpi

AMANDA HAUGHS Community HIGHLIGHTSIn her role as Digital Innovation ToSA, STEAM AND CS magpi.cc/WxKuaDAmanda works with schools and LESSON RESOURCESeducators within San Jose’s CampbellUnion School District, supporting Amanda has created a pack of project resources to aidcross-curricular learning educators in introducing cross-curricular coding into the More recently, Amanda has way to incorporate the use of my classroom within her district. Once news of them madecontinued to integrate the use of grandmother’s hi-tech embroideryRaspberry Pi into the classroom, machine,” she explains in her its way to Twitter, educators across North America wereworking alongside fellow blog post for the project. “RightToSA Misty Kluesner to create away I thought it would be fun to adding them to their classroom toolkit.multimedia art projects based on embroider the Raspberry Pi logothe theme of Awe and Wonder, and from there I realised that aand the Aurora Borealis. This tote bag would be the way to goexploration took the coding practice for my first wearable project.”of computing classes into the artssector of the school, putting the A The result was a tote bagin STEAM where we are beginning made from scratch that includedto see more and more examples of the Raspberry Pi logo andcode in art and design. programmable LED lights. With the conductive thread making up RASPBERRY PI TOTE BAG magpi.cc/nikZJvRight away I thought it While planning her trips to educational conferences and events in 2017, Amanda decided to create somethingwould be fun to embroider eye-catching and a little different. With a little help fromthe Raspberry Pi logo her sewing machine-ninja grandmother, she created the flashing LED Pi Tote. Outside of her work in the outline for the logo, the LEDs RASPBERRY PI magpi.cc/OcglQPeducation, Amanda is a tinkerer. were connected to a Raspberry Pi CERTIFIED EDUCATORWhile planning her attendance Zero, and code controlled how andto multiple education-based when they blinked as she walked Amanda attended Picademy in California, 2016,conferences and events in 2017, from booth to booth at ITSE 2017,she decided to stand apart from the among other events. becoming one of over 400 Raspberry Pi Certifiedcrowd by integrating a RaspberryPi-powered wearable into her In 2015, she was awarded the Educators (RCEs) so far trained in North America.wardrobe. While many wearables PBS Digital Innovator Award,hide their circuits behind folds and followed this up in 2016 with With her Picademy pin in hand, she went on to help theof fabric, Amanda decided to the SVCUA Outstanding Teachercelebrate hers by using conductive Award. With her Raspberry Pi Raspberry Pi North America team train more RCEs atthread and her grandmother’s Certified Educator pin to boot,programmable sewing machine. Amanda continues to work hard, future events.“I loved the idea of making gaining more recognition alongsomething wearable and blinky, the way, and the North Americanand also wanted to figure out a Raspberry Pi community is proud to have her on board.raspberrypi.org/magpi April 2018 91

Community EVENTS 2 KEIM.ZELLE RASPBERRYPI JAM RASPBERRY JAM Oberösterreich, Austria EVENT CALENDAR Find out what community-organised, Raspberry Pi-themed events are happening near you…ABFOINUDT JOAUMT S 3 LROAOSPPBERRY JAM Want a Raspberry Jam in Bangalore, India your area? Want to start one? Email Ben Nuttall about it: [email protected] EVENTS REGULAR EVENTSPI JAM! RASPBERRY JAM PRESTON RASPBERRY JAM LOOPWhen: Thursday 5 April When: Monday 2 AprilWhere: F ab Lab Limerick, When: Saturday 14 April Where: M edia Factory Building, Where: B angalore, India Limerick, Ireland magpi.cc/fNBYEa Preston, UKmagpi.cc/puDVrT magpi.cc/CbQdLNA belated Big Birthday Jam will Are you that person who loves PRJ is a community of peoplebe taking place in Limerick, with who meet in Preston each monthshow-and-tell presentations, all ‘tech stuff’? Then get over to learn, create, and share thedemos, and workshops. potential of Raspberry Pi. to Raspberry Jam LOOP to learn CORNWALL TECH JAM about it! When: Saturday 14 AprilKEIM.ZELLE RASPBERRYPI JAM PI WARS 2018 Where: Cornwall College,When: Saturday 7 April When: Saturday 21 April Camborne, UKWhere: L ichtenberger Strasse 3, Where: C ambridge Computer Lab, cornwalltechjam.uk Learn about coding on a variety Oberösterreich, Austria Cambridge, UK of platforms, including Arduinomagpi.cc/jejESY piwars.org and Raspberry Pi, in variousProgramming sessions for The big moment is here: Raspberry programming languages.children and parents, explained Pi robots duke it out in non-step-by-step so that you can destructive challenges to find outwork at it together. which is the best automaton.92 April 2018 raspberrypi.org/magpi

EVENTS Community WE’VE HIGHLIGHTED SOME OF THE AREAS IN NEED OF A JAM! CAN YOU HELP OUT?8 RLEAESDPSBERRY JAM Leeds, UK5 PRRAESSPTBOENRRY JAM Preston, UK1 PI JAM! Fab Lab, Limerick4 PI WARS 2018 Cambridge, UK7 EGHAM RASPBERRY JAM Staines-upon-Thames, UK6 CORNWALL TECH JAM Camborne, UK EGHAM RASPBERRY JAM RASPBERRY JAM ADVICE: 93 When: Sunday 29 April WHAT TO DO Where: G artner UK HQ, “When I ran the Manchester Jam, people were Staines-upon-Thames, UK happy to work on their own projects. Occasionally magpi.cc/stfIbP we ran a track of talks, or put on a workshop, which Primarily a show-and-tell event was a nice change. Now I run the Jam at Pi Towers, where people bring along their the attendees tended to be mostly beginners – projects for others to try out and usually parents with their children – so we mostly learn from. run workshops and hand out worksheets.” LEEDS RASPBERRY JAM Ben Nuttall Raspberry Jam @ Pi Towers When: Wednesday 2 May Where: S wallow Hill Community Every Raspberry Jam is entitled to apply for a Jam starter kit, which includes magazine issues, printed College, Leeds, UK worksheets, stickers, flyers, and more. Get the magpi.cc/HdaaIj guidebook here: magpi.cc/2q9DHfQ There will be chances to get hands- on with digital making activities April 2018 through the workshop, and a hackspace area to share projects.raspberrypi.org/magpi

Community YOUR LETTERSYOUR LETTERSCATALOGUING RETRO COMPUTINGOLD ISSUES I love the idea, and have long Linux (Slackware!) and onward… wanted to do a RetroPie but… meanwhile the QLs (and monitorsI’m a little bit of a latecomer in the area of trying years back I ran Sinclair QLs, and floppies) sat in storage.to read all the old issues of The MagPi. It’s a tedious and managed to get the game Now running a Core i3 withtask and I have not found a place with a list of all Stellaris, a strategy game, keyed Kubuntu and a Pi 3, with a Pithe contents. I tried to copy-paste them from each in (laboriously, QL SuperBASIC). sitting unused, I thought ‘whymagazine but have not quite succeeded. For some This was at a time when storage not a RetroPie?’ I dug out the QLreason, some of the magazine contents can be was by tape, basically a cassette magazine (QL World, June 1987)copied in a reasonable manner whereas some cannot recording of the tones of the and OCRed the Stellaris program (much easier than typing it all!),– usually requiring some editing. phone-line modems of the dayIs there a catalogue and if not could you please (perhaps 9600 bits per second ending up with a 36kB text filemake one? – a generous estimate, and yes, that includes the author’s player bits!), and before that degraded instructions… and then triedJukka Salo too far I got it over to a 720kB to find a QL emulator. RetroPieThanks for having a go – unfortunately floppy disk.  doesn’t have one.it’s a bit of a big task! We think the best The keyboards failed and I I think there’s one inway to get a good highlight of projects abandoned them. Meanwhile I Windows’ ‘DOS box’ system,and tutorials and reviews is to check had already progressed through but IIRC (it was long ago) I gaveout the Official Projects Books that we IBMs: PC (180kB 5-inch floppy), up trying to get it to run. Longrelease every year. The best of the best extender board, XT (360kB and short: is there a QL emulatormake it into these books, which have a floppy), extended to 640kB, for the Pi (or other Linux),comprehensive contents section as well! 286sx (a rarity – basically an XT or is there someone adept at If anyone has started to create a Get an excellent with a 286 processor), 286, 386 translation that could/wouldcatalogue of all our contents, though, selection of (720kB floppy, but couldn’t read translate the QL SuperBASIC intoplease let us know! We’d be happy projects and the QL disks :( ), a brief fling something that could run onto host it on our GitHub repo and articles the easy with Acorn Electron, 486 (1.44MB the Pi? As I read it, it’s rife withmaintain it diligently. way with our floppy!), Pentium, discovered text boxes spread around the Official Projects Books! screen, and of course the screenRASPBERRY PI DESKTOP geometry is all sorts of strange. Dexter N MuirI understand there is a disc We’ve released a disc with the Keep an eye out Unfortunately we don’t have awhich I can put into my PC Raspberry Pi Desktop on for when we put direct answer for you, Dexter, andthat contains the Raspberry Pi it a couple of times in the a disc on the some of the emulators we triedDesktop for PC? past. However, the easiest cover – it tends to Google don’t all seem to be way to get it if you can’t find to coincide with maintained very well. Hopefully I was told that there was a copy a copy is to download it and major updates one of our intrepid readers willin your magazine which would put it on a USB stick – you to Raspberry Pi get in touch and we can sort outprovide me with instructions can find the downloadable ISO Desktop x86!as well as the disc – what’s the here: magpi.cc/Tdctna. some kind of solution and getsituation on getting a copy if this back to you!is available? From there you can use something like Rufu (rufus.akeo.ie) Digital preservation is an I’m very keen to get my teeth to create a bootable USB stick, and important field at the moment,into this and start learning some then just follow our video on how especially with games andnew skills. Hopefully you can to install it: magpi.cc/DEOVGR. It’s computer systems slowly dyinghelp me. really that easy! without much fanfare. Maybe this could be a step towards savingPaul more old tech?94 April 2018 raspberrypi.org/magpi

YOUR LETTERS CommunityFROM THE FORUM:HACKSPACEMAGAZINE DISCOUNTSThe Raspberry Pi Forum is a hotbed ofconversations and problem-solvingfor the community – join in viaraspberrypi.org/forumsI s the discount still available for The MagPi subscribers for HackSpacemagazine? I didn’t subscribe earlyas I wanted to make sure the content wasconsistently good and not just for the firstcouple of issues. MAKE BUILD HACK CREATELouisPIf you’re a year- TECHNOLOGY IN YOUR HANDS hsmag.cc April 2018 Issue #05long subscriber to 05The MagPi, your RASPBERRY PI 3B+ 9 772515 514006discount code Apr.2018for HackSpace &Fansetetwr porrokcinegssor Issue #05 £6magazine HDARCEMKIENLG RESIN.IO Turn your hand tool Cdoenvitcreosl awllityhouornsemtoaortl into a table saw FASHILOEND Bring your accessories to life with LEDsshouldn’t expire. LADYADAWe had some LIMOR FRIED REVEALS ADAFRUIT’S SECRETS TO MAKING GREAT HARDWAREproblems withthe original LITHOPHANES CHEERLIGHTS PENCILS NEURAL NETWORKSdiscount codebeing leaked, though, so if you’re having troublesorting out your discount, please drop us a lineand we can try to sort it out.WRITE TO USHave you got something you’d like to say?Get in touch via [email protected] or on TheMagPi section of the forum at: raspberrypi.org/forumsraspberrypi.org/magpi April 2018 95



IN ASSOCIATION WITH: 10MEARM PI KITSWe’ve teamed up with Mime Industriesto offer ten of these fantastic robotarm kits for Raspberry Pi.We reviewed the MeArm Pi in issue #62and found it “a joy to build and use”. Youcan control the MeArm Pi using the twinjoysticks, or with code. MSaakyers “The MeArm Pi isan easy-to-build robotarm kit that’s designedto get children (andadults!) learningabout technology,engineering, andprogramming.”Mime IndustriesEnter now at magpi.cc/win Learn more: shop.mime.co.ukTerms & ConditionsCompetition opens on 28 March 2018 and closes on 19 April 2018. Prize is offered to participants worldwide aged 13 or over, except employees of the RaspberryPi Foundation, the prize supplier, their families or friends. Winners will be notified by email no more than 30 days after the competition closes. By entering thecompetition, the winner consents to any publicity generated from the competition, in print and online. Participants agree to receive occasional newsletters from TheMagPi magazine. We don’t like spam: participants’ details will remain strictly confidential and won’t be shared with third parties. Prizes are non-negotiable and nocash alternative will be offered. This promotion is in no way sponsored, endorsed or administered by, or associated with, Instagram or Facebook.raspberrypi.org/magpi April 2018 97

Column THE FINAL WORD MATT RICHARDSON Matt Richardson is the Executive Director of the Raspberry Pi Foundation North America and author of Getting Started with Raspberry Pi. Contact him on Twitter @MattRichardson. CHEERS TO THE COMMUNITY Matt Richardson’s take on ensuring community growth for years to comeJ ust a few weeks ago we celebrated the sixth of a single individual makes a huge difference in the birthday of Raspberry Pi. To mark the occasion, quality and sustainability of a recurring event like a Jam. there were ‘Big Birthday Weekend’ RaspberryJams all over the world. They took place at Raspberry Pi’s If you don’t have a Jam near you, you can start one.birthplace Cambridge, to my home town Philadelphia, all You don’t need permission from us, but if you registerthe way to Tokyo, and pretty much everywhere in between. your Jam, we can put it on the Jam map and make sure Watching these worldwide Jams on Twitter was that other Raspberry Pi community members knowincredible and a reminder of how large, how widespread, about it. Don’t be intimidated by the big Jams you mayand how enthusiastic the Raspberry Pi community is. The have seen online or in The MagPi. A Jam often starts withsuccess of the Raspberry Pi over the last six years is due in just a few people getting together on a regular basis to share the projects they’re making with Raspberry Pi.We owe so much of the success Join the forumof Raspberry Pi to the amazingcommunity around it Another way to support the Raspberry Pi community is to participate in the forum: raspberrypi.org/forums. Whether you’re sharing a project you made, asking questions, providing guidance to others,very large part to this community, which includes makers, or just chatting in the off-topic area, it’s such a greatdevelopers, educators, tech geeks, engineers, gamers, way for our community to stay connected. And withartists, and many more. over a million posts, the forum has become a massiveWe’re a diverse group of people and we’re all over the knowledge base.globe. But we have something in common. We know The Raspberry Pi is a computer made for making. Sothat affordable and accessible technology like Raspberry sharing what you create with Raspberry Pi is a greatPi is a powerful force in the world. Raspberry Pi brings way to recruit new members to join our community.computing and digital making to more people so that they Part of this is just showing off what Raspberry Pi iscan solve problems, express themselves, and have fun. capable of. And if you’re sharing the steps to how youGet Jammin’ made your project, you’re contributing to the wealth of online knowledge about Raspberry Pi in addition toThere are some ways that all of us can ensure that this empowering others to make.valuable community is growing and can sustain itself We owe so much of the success of Raspberry Pi andfor many years ahead. First, if there’s a Jam happening the Raspberry Pi Foundation to the amazing communitynear you, all you have to do is show up. Even if you don’t around it. When you participate in the community byhave anything to share, it’s a great opportunity to show going to Jams, engaging in the forums, and sharingyour support and meet other community members. Even what you make, you’re helping to make sure that it willbetter, you can offer help to your local Jam organiser. be around for a long time. Here’s to another six years ofHaving a team of collaborators working on a Jam instead this kick-ass community!98 April 2018 raspberrypi.org/magpi

LEARN CTHOEMEAPSUYTWINAYG! Includes Pi Zero W computer   Official case with three covers   USB and HDMI adaptors   8GB Micro SD card 116-page beginner’s bookBuy online: magpi.cc/store


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook