Most Raspberry Pi projects we feature debut privately and with little fanfare – at least until they’re shared by us.
The El Carrillon project, however, could hardly have made a more public entrance. In September 2019 it was a focal point of Argentina’s 49th annual Fiesta Nacional de la Flor (National Flower Festival), where its newly overhauled bell tower proudly rang out a brand-new, Raspberry Pi-enabled tune.
Many years ago, festival organisers created custom hardware with a PIC (programmable interface) microcontroller to control 18 tuned bells. Each bell is associated with a musical note, from A3 to D5 with all the semitones. Until its long overdue update, the tower’s 18 bells had rung the tune to Ayer, also known as Yesterday by The Beatles. They now have a brand-new repertoire of MIDI-based tunes, including the theme from Star Wars.
For Gerardo Richarte, the originator of the project, there was a little extra pressure: his dad is on the board of the NGO that organises Fiesta Nacional de la Flor, and challenged his son to come up with a way to update the bells so different songs could be played.
With the challenge accepted, Mariano Martinez Peck explains, “We chose Raspberry Pi because it was inexpensive, yet powerful enough to run Linux, Python, and VA Smalltalk. We could find ready-made HATs that actually matched the pinout of the existing flat cables without much hacking, and only a minimal amount of other hardware was needed. In addition, there was plenty of documentation, materials, tutorials, and GPIO libraries available.”
The bells had a pre-existing driver module
The project aim was to be able to run a mobile-friendly website within Raspberry Pi Zero that allowed control, configuration, and playback of MIDI songs on the bell tower. “In addition, we wanted to allow live playing from a MIDI keyboard,” says Mariano. The project developed as a live test and iteration update, but the final build only came together when Mariano and Gerardo’s moment in the spotlight arrived and El Carrillon rang out the first new tunes.
The decades-old chimes were controlled by assembly code. This was superseded by Python when the team made the switch to Raspberry Pi Zero. Mariano explains, “Raspberry Pi allowed us to use Python to directly interface with both the old and new hardware and get the initial project working.”
However, the Python code was itself replaced by object-oriented VA Smalltalk code – an environment both Mariano and Gerardo are adept at using. Mariano says, “Smalltalk’s live programming environment works really well for fast, iterative development and makes software updates quick and easy without the need for recompilation that lower-level languages [such as assembly or C/C++] would need.”
El Carrillon’s bells can now play any MIDI file on Raspberry Pi, and the notes of the song will be mapped to the tuned bells. However, as the testing process revealed, some songs are more recognisable than others when reproduced on chimes.
A final feature enabled Gerardo to bag some brownie points with his father-in-law. He recently added a web interface for controlling, configuring, and playing songs, meaning the bells can now be controlled remotely and the song selected via a smartphone app.
The El Carrillon bell tower forms a striking backdrop to the flower festival and other cultural events
Find more amazing projects and tutorials in The MagPi #92, out now! You can get The MagPi #92 online at our store, or in print from all good newsagents and supermarkets. You can also access The MagPi magazine via our Android and iOS apps.
Don’t forget our fantastic subscription offers, which include a free gift of a Raspberry Pi Zero W when you subscribe for twelve months.
And, as with all our Raspberry Pi Press publications, you can download the free PDF from our website.
Gun down the clay pigeons in our re-creation of a classic minigame from Konami’s Hyper Sports. Take it away, Mark Vanstone…
Hyper Sports’ Japanese release was tied in with the 1984 Summer Olympics.
Konami’s sequel to its 1983 arcade hit, Track & Field, Hyper Sports offered seven games – or events – in which up to four players could participate. Skeet shooting was perhaps the most memorable game in the collection, and required just two buttons: fire left and fire right.
The display showed two target sights, and each moved up and down to come into line with the next clay disc’s trajectory. When the disc was inside the red target square, the player pressed the fire button, and if their timing was correct, the clay disc exploded. Points were awarded for being on target, and every now and then, a parrot flew across the screen, which could be gunned down for a bonus.
To make a skeet shooting game with Pygame Zero, we need a few graphical elements. First, a static background of hills and grass, with two clay disc throwers each side of the screen, and a semicircle where our shooter stands – this can be displayed first, every time our draw() function is called.
We can then draw our shooter (created as an Actor) in the centre near the bottom of the screen. The shooter has three images: one central while no keys are pressed, and two for the directions left and right when the player presses the left or right keys. We also need to have two square target sights to the left and right above the shooter, which we can create as Actors.
When the clay targets appear, the player uses the left and right buttons to shoot either the left or right target respectively.
To make the clay targets, we create an array to hold disc Actor objects. In our
update() function we can trigger the creation of a new disc based on a random number, and once created, start an animation to move it across the screen in front of the shooter. We can add a shadow to the discs by tracking a path diagonally across the screen so that the shadow appears at the correct Y coordinate regardless of the disc’s height – this is a simple way of giving our game the illusion of depth. While we’re in the
update() function, looping around our disc object list, we can calculate the distance of the disc to the nearest target sight frame, and from that, work out which is the closest.
When we’ve calculated which disc is closest to the right-hand sight, we want to move the sight towards the disc so that their paths intersect. All we need to do is take the difference of the Y coordinates, divide by two, and apply that offset to the target sight. We also do the same for the left-hand sight. If the correct key (left or right arrows) is pressed at the moment a disc crosses the path of the sight frame, we register a hit and cycle the disc through a sequence of exploding frames. We can keep a score and display this with an overlay graphic so that the player knows how well they’ve done.
And that’s it! You may want to add multiple players and perhaps a parrot bonus, but we’ll leave that up to you.
You can read more features like this one in Wireframe issue 35, available now at Tesco, WHSmith, and all good independent UK newsagents.
Or you can buy Wireframe directly from Raspberry Pi Press — delivery is available worldwide. And if you’d like a handy digital version of the magazine, you can also download issue 35 for free in PDF format.
The post Code Hyper Sports’ shooting minigame | Wireframe #35 appeared first on Raspberry Pi.
When you’re part of the Raspberry Pi Foundation community, you’re a part of a global family of young creators who bring things to life with the power of digital making. We imagine that, given the current changes we’re all navigating, there are probably more of you who are interested in creating new and exciting things at home. And we want to help you! One of the best things we can do right now is to tap into what connects us as a community, and that’s digital making. So, welcome to Digital Making at Home from the Raspberry Pi Foundation!
Find out more about Digital Making at Home at http://rpf.io/home Find more digital making projects at http://rpf.io/projects Find out more about the #Raspber…
Whether you wrote your first line of code years ago or minutes ago, or you’ve yet to get started, with Digital Making at Home we’re inviting you on a digital making adventure each week.
At the start of each week, we will share a theme that’s designed to jumpstart your journey of creative expression and problem solving where you create a digital making project you’re proud of. Every week, we’ll have code-along videos led by people from our team. They will walk you through projects from our free projects collection, to give you a place to start and a friendly face to accompany you!
For those of you whose mother language isn’t English, our free project guides are available in up to 30 languages so far.
Each week, when you’ve made something you love using digital making, you can share it with us! Just make sure you have your parent’s or guardian’s permissions first. Then share your project by filling out this form. You might find one of your projects featured in a future blog post for the whole community to see, but no matter what, we want to see what you created!
Just because we’re all at home, that doesn’t mean we can’t create together, so let’s kick off Digital Making at Home with this week’s theme:
Playing a game is a fun way to pass the time, but why not take it to the next level and make your own game? This week, we invite you to create a game that you can play with your friends and family!
Let your imagination run free, and if you’re not sure where to start, here are three code-along videos to help you.
If you’re new to coding, we want to introduce you to Scratch, a block-based coding language that is perfect to start with.
Try out Archery, led by Mr C and his sidekick Xavier:
Access the project guide at http://rpf.io/archery Find out more about Digital Making at Home at http://rpf.io/home Share your thoughts about this content: ht…
Go to the free Archery project guide (also available in Polish).
If you’re looking to go beyond the Scratch surface, dive a little deeper into the coding language with.
Try out CATS!, led by Christina:
Access the project guide at http://rpf.io/cats Find out more about Digital Making at Home at http://rpf.io/home Share your thoughts about this content: https…
If you’re all Scratched out, move on to Python, a text-based coding language, to take things up a notch.
Try out Turtle Race, led by Marc:
Access the project guide at http://rpf.io/turtle-race Find out more about Digital Making at Home at http://rpf.io/home Share your thoughts about this content…
Go to the free Turtle Race project guide (available in 16 languages).
If you’re creating a game in Scratch, check out the extra videos from Mr C in the ‘Digital Making at Home: Making games’ playlist. These will show you how to add a timer, or a score, or a game over message, or a cool starter screen to any Scratch game!
And if you’re into Python coding and hungry for more creative inspiration, we’ve got you covered. Our own Wireframe magazine, which you can download for free, has a ton of resources about making games. The magazine’s Source Code series shows you how to recreate an aspect of a classic game with a snippet of Python code, and you can read articles from that series on the Raspberry Pi blog. And if that’s still not enough, take a look at our Code the Classics book, which you can also download for free!
Alright friends, you’ve got all you need, so let’s get digital making!
We’d love to know what you think of Digital Making at Home, so that we can make it better for you! Let us know your thoughts by filling in this form.
Raspberry Pi devices are often used by scientists, especially in biology to capture and analyse data, and a particularly striking – and sobering – project has made the news this week. Researchers at UMass Amherst have created FluSense, a dictionary-sized piece of equipment comprising a cheap microphone array, a thermal sensor, an Intel Movidius 2 neural computing engine, and a Raspberry Pi. FluSense monitors crowd sounds to forecast outbreaks of viral respiratory disease like seasonal flu; naturally, the headlines about their work have focused on its potential relevance to the COVID-19 pandemic.
Forsad Al Hossain and Tauhidur Rahman with the FluSense device. Image courtesy of the University of Massachusetts Amherst
The device can distinguish coughing from other sounds. When cough data is combined with information about the size of the crowd in a location, it can provide an index predicting how many people are likely to be experiencing flu symptoms.
It was successfully tested in in four health clinic waiting rooms, and now, PhD student Forsad Al Hossain and his adviser, assistant professor Tauhidur Rahman, plan to roll FluSense out in other large spaces to capture data on a larger scale and strengthen the device’s capabilities. Privacy concerns are mitigated by heavy encryption, and Al Hossain and Rahman explain that the emphasis is on aggregating data, not identifying sickness in any single patient.
The researchers believe the secret to FluSense’s success lies in how much of the processing work is done locally, via the neural computing engine and Raspberry Pi: “Symptom information is sent wirelessly to the lab for collation, of course, but the heavy lifting is accomplished at the edge.”
Image courtesy of the University of Massachusetts Amherst
FluSense offers a different set of advantages to other tools, such as the extremely popular self-reporting app developed by researchers at Kings College Hospital in London, UK, together with startup Zoe. Approaches like this rely on the public to sign up, and that’s likely to skew the data they gather, because people in some demographic groups are more likely than others to be motivated and able to participate. FluSense can be installed to capture data passively from groups across the entire population. This could be particularly helpful to underprivileged groups who are less likely to have access to healthcare.
Makers, engineers, and scientists across the world are rising to the challenge of tackling COVID-19. One notable initiative is the Montreal General Hospital Foundation’s challenge to quickly design a low-cost, easy to use ventilator which can be built locally to serve patients, with a prize of CAD $200,000 on offer. The winning designs will be made available to download for free.
There is, of course, loads of chatter on the Raspberry Pi forum about the role computing has in beating the virus. We particularly liked this PSA letting you know how to free up some of your unused processing power for those researching treatments.
Screenshot via @deeplocal on Instagram
And to end on a cheering note, we *heart* this project from @deeplocal on Instagram. They’ve created a Raspberry Pi-powered soap dispenser which will play 20 seconds of your favourite song to keep you at the sink and make sure you’re washing your hands for long enough to properly protect yourself.
Using deeper learning as a framework for transformative educational experiences, Brent Richardson outlines the case for a pedagogical approach that challenges students using a Raspberry Pi. From the latest issue of Hello World magazine — out today!
A benefit of completing school and entering the workforce is being able to kiss standardised tests goodbye. That is, if you don’t count those occasional ‘prove you watched the webinar’ quizzes some supervisors require.
In the real world, assessments often happen on the fly and are based on each employee’s ability to successfully complete tasks and solve problems. It is often obvious to an employer when their staff members are unprepared.
Formal education continues to focus on accountability tools that measure base-level proficiencies instead of more complex skills like problem-solving and communication.
One of the main reasons the U.S. education system is criticised for its reliance on standardised tests is that this method of assessing a student’s comprehension of a subject can hinder their ability to transfer knowledge from an existing situation to a new situation. The effect leaves students ill-prepared for higher education and the workforce.
A study conducted by the National Association of Colleges and Employers found a significant gap between how students felt about their abilities and their employer’s observations. In seven out of eight categories, students rated their skills much higher than their prospective employers had.
Some people believe that this gap continues to widen because teaching within the confines of a standardised test encourages teachers to narrow their instruction. The focus becomes preparing students with a limited scope of learning that is beneficial for testing.
With this approach to learning, it is possible that students can excel at test-taking and still struggle with applying knowledge in new ways. Educators need to have the support to not only prepare students for tests but also to develop ways that will help their students connect to the material in a meaningful manner.
In an effort to boost the U.S. education system’s ability to increase the knowledge and skills of students, many private corporations and nonprofits directly support public education. In 2010, the Hewlett Foundation went so far as to develop a framework called ‘deeper learning’ to help guide its education partners in preparing learners for success.
Deeper learning focuses on six key competencies:
This framework ensures that learners are active participants in their education. Students are immersed in a challenging curriculum that requires them to seek out and acquire new information, apply what they have learned, and build upon that to create new knowledge.
While deeper learning experiences are important for all students, research shows that schools that engage students from low-income families and students of colour in deeper learning have stronger academic outcomes, better attendance and behaviour, and lower dropout rates. This results in higher graduation rates, and higher rates
of college attendance and perseverance than comparison schools serving similar students. This pedagogical approach is one we strive to embed in all our work at Fab Lab Houston.
The importance of deeper learning was undeniable when a group of students I worked with in Houston built a solar-powered time-lapse camera. Through this collaborative project, we quickly found ourselves moving beyond classroom pedagogy to a ‘hero’s journey’ — where students’ learning paths echo a centuries-old narrative arc in which a protagonist goes on an adventure, makes new friends, encounters roadblocks, overcomes adversity, and returns home a changed person.
In this spirit, we challenged the students with a simple objective: ‘Make a device to document the construction of Fab Lab Houston’. In just one sentence, participants understood enough to know where the finish line was without being told exactly how to get there. This shift in approach pushed students to ask questions as they attempted to understand constraints and potential approaches.
Students shared ideas ranging from drone video to photography robots. Together everyone began to break down these big ideas into smaller parts and better define the project we would tackle together. To my surprise, even the students that typically refused to do most things were excited to poke holes in unrealistic ideas. It was decided, among other things, that drones would be too expensive, robots might not be waterproof, and time was always a concern.
The decision was made to move forward with the stationary time-lapse camera, because although the students didn’t know how to accomplish all the aspects of the project, they could at least understand the project enough to break it down into doable parts and develop a ballpark budget. Students formed three teams and picked one aspect of the project to tackle. The three subgroups focused on taking photos and converting them to video, developing a remote power solution, and building weatherproof housing.
A group of students found sample code for Raspberry Pi that could be repurposed to take photos and store them sequentially on a USB drive. After quick success, a few ambitious learners started working to automate the image post-processing into video. Eventually, after attempting multiple ways to program the computer to dynamically turn images into video, one team member discovered a new approach: since the photos were stored with a sequential numbering system, thousands of photos could be loaded into Adobe Premiere Pro straight off the USB with the ‘Automate to Sequence’ tool in Premiere.
A great deal of time was spent measuring power consumption and calculating solar panel and battery size. Since the project would be placed on a pole in the middle of a construction site for six months, the students were challenged with making their solar-powered time-lapse camera as efficient as possible.
Waking the device after it was put into sleep mode proved to be more difficult than anticipated, so a hardware solution was tested. The Raspberry Pi computer was programmed to boot up when receiving power, take a picture, and then shut itself down. With the Raspberry Pi safely shut down, a timer relay cut power for ten minutes before returning power and starting the cycle again.
Finally, a waterproof container had to be built to house the electronics and battery. To avoid overcomplicating the process, the group sourced a plastic weatherproof ammunition storage box to modify. Students operated a 3D printer to create custom parts for the box.
After cutting a hole for the camera, a small piece of glass was attached to a 3D-printed hood, ensuring no water entered the box. On the rear of the box, they printed a part to hold and seal the cable from the solar panel where it entered the box. It only took a few sessions before the group produced a functioning prototype. The project was then placed outside for a day to test the capability of the device.
The test appeared successful when the students checked the USB drive. The drive was full of high-quality images captured every ten minutes. When the drive was connected back to Raspberry Pi, a student noticed that all the parts inside the case moved. The high temperature on the day of the test had melted the glue used to attach everything. This unexpected problem challenged students to research a better alternative and reattach the pieces.
Once the students felt confident in their device’s functionality, it was handed over to the construction crew, who installed the camera on a twenty-foot pole. The installation went smoothly and the students anxiously waited to see the results.
Less than a week after the camera went up, Houston was hit hard with the rains brought on by hurricane Harvey. The group was nervous to see whether the project they had constructed would survive. However, when they saw that their camera had survived and was working, they felt a great sense of pride.
They recognised that it was the collaborative effort of the group to problem-solve possible challenges that allowed their camera to not only survive but to capture a spectacular series of photos showing the impact of the hurricane in the location it was placed.
This is “BakerRipleyTimeLapse2” by Brent Richardson on Vimeo, the home for high quality videos and the people who love them.
Overcoming many hiccups throughout the project was a great illustration of how the students learned how to learn and
to develop an academic mindset; a setback that at the beginning of the project might have seemed insurmountable was laughable in the end.
Throughout my experience as a classroom teacher, a museum educator, and now a director of a digital makerspace, I’ve seen countless students struggle to understand the relevance of learning, and this has led me to develop a strong desire to expand the use of deeper learning.
Sometimes it feels like a risk to facilitate learning rather than impart knowledge, but seeing a student’s development into a changed person, ready to help someone else learn, makes it worth the effort. Let’s challenge ourselves as educators to help students acquire knowledge and use it.
Issue 12 of Hello World is available now as a FREE PDF download. UK-based educators can also subscribe to receive Hello World directly to their door in all its shiny printed goodness. Visit the Hello World website for more information.
The post Using Raspberry Pi for deeper learning in education appeared first on Raspberry Pi.
It is time. Time to go to that little stack of gifts from well-wishers who have badged you as “techie” or noted that you “play computer games”. Armed with this information, they decided you’d like to receive one of our small and perfectly formed Raspberry Pis. You were thrilled. You could actually make a thing.
Except you haven’t. You had to go to that job thingy, and talk to that partner thingy, and wash and feed those children thingies. Don’t worry, we’re not offended. We know that embarking on your first coding project is daunting and that the community has taken off like a rocket so there are eight bajillion ideas floating around. Good job we’re here to help, then, isn’t?
Some of us have found ourselves spending more time with our online communities recently. Those whose digital family of choice is to be found on Reddit should see an uptick in their personal ‘Karma’ if they’re spending more time digging into “the front page of the internet”. If you’d like to see a real-world indicator of the fruits of your commenting/sharing/Let-Me-Google-That-For-You labour, a super-easy Raspberry Pi first-timer project is building a Karma counter, like this one we found on Reddit.
Now, Squiddles1227 is one of those flash 3D printer-owning types, but you could copy the premise and build your own crafty Karma-themed housing around your counter.
On a similar note (and featuring a comprehensive ‘How To’), GiovanniBauer on instructables.com used his Raspberry Pi to create an Instagram follower counter. Developed on Raspbian with Node.js, this project walk-through should get you started on whichever social media counter project you’d like to have a bash at.
We know this is a real-life Raspberry Pi first-timer project because the Reddit post title says so. Ninjalionman1 made an e-ink calendar using a Raspberry Pi Zero so they can see their daily appointments, weather report, and useful updates.
We mined the original Reddit thread to find you the comment linking to all the info you need about hardware and setup. Like I said, good job we’re here.
Raspberry Pi 3 and 4, as well as Raspberry Pi Zero W, come with built-in Bluetooth connectivity. This means you can build something to let your lockdown-weary self take your emotional-health-preserving music/podcasts/traditional chant soundtrack with you as you migrate around your living space. “Mornings in the lounge… mid-afternoons at the kitchen table…” – we feel you.
Circuitdigest.com posted this comprehensive walk-through to show you how a Raspberry Pi can convert an ordinary speaker with a 3.5mm jack into a wireless Bluetooth speaker.
PCWorld.com shared 10 Raspberry Pi projects they bet anyone can do, and we really like the look of this one. It shows you how to give a “dumb” TV extra smarts, like web browsing, which could be especially useful if screen availability is limited in a multi-user household.
The PCWorld article recommends using a Raspberry Pi 2, 3 or 4, and points out that this is a much cheaper option than things like Chromebits and Compute Sticks.
Lastly, electromaker.io have hidden the coding education vegetables in the Minecraft tomato sauce using Raspberry Pi. The third post down on this thread features a video explaining how you can hack your kids’ favourite game to get them learning to code.
The video blurb also helpfully points out that Minecraft comes pre-installed on Raspbian, making it “one of the greatest Pi projects for kids.”
If you’re not quite ready to jump in and try any of the above, try working your way through these really simple steps to set up your Raspberry Pi and see what it can do. Then come back here and try one of these first-timer projects, share the results of your efforts, tag us, and receive a virtual round of applause!
The post Ashley’s top five projects for Raspberry Pi first-timers appeared first on Raspberry Pi.
While being holed up in the Vaults living off our stash of Nuke cola, we’ve come across this mammoth junk-build project, which uses Raspberry Pi Zero W to power a working Pipboy.
UK-based JustBuilding went full Robert House and, over several months, built the device’s body by welding together scrap plastic. Raspberry Pi Zero W serves as the brain, with a display header mounted to the GPIO pins. The maker wrote a Pipboy-style user interface, including demo screens, in Python — et voilà…
Lucky for him, semiconductors were already invented but, as JustBuilding admits, this is not what we’d call a beginner’s project. Think the Blue Peter show’s Tracey Island extravaganza, except you don’t have crafty co-presenters/builders, and you also need to make the thing do something useful (for our US readers who just got lost there, think Mr Rogers with glitter glue and outdoor adventure challenges).
The original post on Instructables is especially dreamy, as JustBuilding has painstakingly produced a really detailed, step-by-step guide for you to follow, including in-the-making photos and links to relevant Raspberry Pi forum entries to help you out where you might get stuck along the way.
And while Raspberry Pi can help you create your own post-apocalyptic wristwear, we’re still working on making that Stealthboy personal cloaking device a reality…
If you’re lucky enough to have access to a 3D printer, the following is the kind of Pipboy you can knock up for yourself (though we really like JustBuilding’s arts’n’crafts upcycling style):
Find out how to 3D print and build your own functional Pipboy 3000 using a Raspberry Pi and Adafruit 3.5″ PiTFT. The pypboy python program for the Raspberry …
The post Stay busy in your Vault with a Raspberry Pi Zero Pipboy appeared first on Raspberry Pi.
Connect your gaming PC to your TV with ease, thanks to Steam Link and Raspberry Pi.
Back in 2018, we asked Simon, our
Asset Management Assistant Keeper of the Swag, Organiser of the Stuff, Lord Commander of the Things to give Steam Link on Raspberry Pi a try for us, as he likes that sort of thing and was probably going to do it anyway.
Valve’s Steam Link, in case you don’t know, allows users of the gaming distribution platform Steam to stream video games from their PC to a display of their choice via their home network, with no need for cumbersome wires and whatnot.
Originally produced as a stand-alone box in 2018, Valve released this tool as a free download to all Raspberry Pi users, making it accessible via a single line of code. Nice!
The result of Simon’s experiment was positive: he reported that setting up Steam Link was easy, and the final product was a simple and affordable means of playing PC games on his TV, away from his PC in another room.
Well, it’s 2020 and since many of us are staying home lately, so we figured it would be nice to remind you all that this streaming service is still available.
To set up Steam Link on your Raspberry Pi, simply enter the following into a terminal window:
sudo apt update sudo apt install steamlink
At the Raspberry Pi Foundation, our mission is to put the power of computing and digital making into the hands of people all over the world. We know that a lot of families around the globe are navigating school closures and practicing social distancing right now to keep their communities healthy and safe.
So in today’s post, we put together a list for you with some of our free online projects and resources that digital makers of all ages and experience levels can explore at home.
For most of these projects, you don’t need any new software or hardware. And many of our online resources are available in multiple languages, so young learners can use them even if their mother language isn’t English!
Our team is working hard to bring you more online learning experiences to support you, your children, and everyone in the community at this time. You can read our CEO Philip Colligan’s message about how we are responding to the novel coronavirus. And for people who are involved in running Code Clubs, CoderDojos, or Raspberry Jams, we’ve specifically put together guidance on how to keep your learners engaged.
We want to make sure digital makers of all ages have the resources they need to explore and create with code. What do you think of these activities, and what else would you like to see? Tell us in the comments below!
In HackSpace magazine issue 28 we had a look at how to create an ultrasonic controller for a version of Pong called Boing!. This month, we’re going to take a step further forward through video game history and look at the game Frogger. In this classic game, you control a frog as it makes its way across logs, roads, and train tracks, avoiding falling in the water or getting hit.
The tribute to Frogger in the new Code the Classics Volume 1 book is called Infinite Bunner, and works in much the same way, except you control a bunny.
Jump along the logs, dodge the traffic, avoid the trains, and keep your bunny alive for as long as possible
All this hopping got us thinking about a controller. Our initial idea was that since the animals jump, so should the controller. An accelerometer can detect freefall, so it shouldn’t be too hard to convert that into button presses. However, it turns out that computer-controlled frogs and rabbits can jump much, much faster than humans can, and we really struggled to get a working game mechanic, so we compromised a little and worked with ‘flicks’.
The basic idea is that you tilt the controller left or right to move left or right, but you have to flick it up to register a jump (simply holding it upright won’t work).
We’ve used a Circuit Playground Bluefruit as our hardware, but it would work equally well with a Circuit Playground Express. There are two key parts to the software. The first is reading in accelerometer values and use these to know what orientation the board is in, and the second is the board mimicing a USB keyboard and sending keystrokes to any software running on it.
The first step is to get Infinite Bunner working on your machine.
Get your copy of Code the Classics today
You can download the code for all the Code the Classics Volume 1 games here. Click on
Clone or Download > Download ZIP. Unzip the download somewhere.
You’ll need Python 3 with Pygame Zero installed. The process for this differs a little between different computers, but there’s a good overview of all the different options on page 186 of Code the Classics.
Subscribe to HackSpace magazine for twelve months and you get a Circuit Playground Express for free! Then you can make your very own Infinite Bunner controller
Once everything’s set up, open a terminal and navigate to the directory you unzipped the code in. Then, inside that, you should find a folder called
bunner-master and move into that. You can then run:
Have a few goes playing the game, and you’ll find that you need the left, right, and up arrow keys to play (there is also the down arrow, but we’ve ignored this since we’ve never actually used it in gameplay – if you’re a Frogger/Bunner aficionado, you may wish to implement this as well).
Reading the accelerometer is as easy as importing the appropriate module and running one line:
from adafruit_circuitplayground import cpx, y, z = cp.acceleration
Sending key presses is similarly easy. You can set up a keyboard with the following:
from adafruit_hid.keyboard import Keyboard from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS from adafruit_hid.keycode import Keycode keyboard = Keyboard(usb_hid.devices)
Then send key presses with code such as this:
time.keyboard.press(Keycode.LEFT_ARROW) time.sleep(0.1) keyboard.release_all()
The only thing left is to slot in our mechanics. The X-axis on the accelerometer can determine if the controller is tilted left or right. The output is between 10 (all the way left) and -10 (all the way right). We chose to threshold it at 7 and -7 to require the user to tilt it most of the way. There’s a little bit of fuzz in the readings, especially as the user flicks the controller up, so having a high threshold helps avoid erroneous readings.
The Y-axis is for jumping. In this case, we require a ‘flap’ where the user first lifts it up (over a threshold of 5), then back down again.
The full code for our controller is:
import time from adafruit_circuitplayground import cp import usb_hid from adafruit_hid.keyboard import Keyboard from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS from adafruit_hid.keycode import Keycode keyboard = Keyboard(usb_hid.devices) jumping = 0 up=False while True: x, y, z = cp.acceleration if abs(y) > 5: up=True if y < 5 and up: keyboard.press(Keycode.UP_ARROW) time.sleep(0.3) keyboard.release_all() up=False if x < -7 : keyboard.press(Keycode.LEFT_ARROW) time.sleep(0.1) keyboard.release_all() if x < 7 : keyboard.press(Keycode.RIGHT_ARROW) time.sleep(0.1) keyboard.release_all() time.sleep(0.1) if jumping > 0: jumping=jumping-1
It doesn’t take much CircuitPython to convert a microcontroller into a games controller
The final challenge we had was that there’s a bit of wobble when moving the controller around – especially when trying to jump repeatedly and quickly. After fiddling with thresholds for a while, we found that there’s a much simpler solution: increase the weight of the controller. The easiest way to do this is to place it inside a book. If you’ve ever held a copy of Code the Classics, you’ll know that it’s a fairly weighty tome. Just place the board inside and close the book around it, and all the jitter disappears.
That’s all there is to the controller. You can use it to play the game, just as you would any joypad. Start the game as usual, then start flapping the book around to get hopping.
Code the Classics is available from Raspberry Pi Press as well, and comes with free UK shipping. And here’s a lovely video about Code the Classics artist Dan Malone and the gorgeous artwork he created for the book:
The post Build a physical game controller for Infinite Bunner appeared first on Raspberry Pi.
Looking to build their own ergonomic mechanical split keyboard, Gosse Adema turned to the Raspberry Pi Zero W for help.
Gosse has been happily using a Microsoft Natural Elite keyboard for years. You know the sort, they look like this:
Twenty years down the line, the keyboard has seen better days and, when looking for a replacement, Gosse decided to make their own.
This is my the first mechanical keyboard project. And this will be for daily usage. Although the possibilities are almost endless, I limit myself to the basic functionality: An ergonomic keyboard with mouse functions.
While searching for new switched, Gosse came across a low-profile Cherry MX that would allow for a thinner keyboard. And what’s the best device to use when trying to keep the profile of your project as thin as possible? Well, hello there, Raspberry Pi Zero W, aren’t you looking rather svelte today.
After deciding to use a Raspberry Pi as the keyboard controller over other common devices, Gosse took inspiration from an Adafruit tutorial on turning Raspberry Pi into a USB gadget, and from “the usbarmory Github page of Chris Kuethe”, which describes how to create a USB gadget with a keyboard.
There is a lot *A LOT* of information on how Gosse built the keyboard on Instructables and, if we try to go into any detail here, our word count is going to be in the thousands. So, let’s just say this: the project uses some 3D printing, some Python code, and some ingenuity to create a lovely-looking final keyboard. If you want to make your own, Gosse has provided absolutely all the information you need to do so. So check it out, and be sure to give Gosse some love via the comments section on Instructables.
Also, if you’re unsure of how a mechanical keyboard differs from other keyboards, we made this handy video for you all!
So, what makes a mechanical keyboard ‘mechanical’? And why are some mechanical keyboards more ‘clicky’ than others? Custom PC’s Edward Chester explains all. …
The post Building a split mechanical keyboard with a Raspberry Pi Zero controller appeared first on Raspberry Pi.
Yoshi aside, we can’t think of anyone who isn’t a fan of the double jump. In their latest video, the Wireframe magazine team take a deep(ish) dive into one of video gaming’s most iconic moves.
The humble jump got a kick in 1984 with the introduction of the double jump, a physicist’s worst nightmare and one of video gaming’s most iconic moves. Subsc…
Are you looking to upgrade your computer monitor? Last week, Custom PC magazine, a publication of Raspberry Pi Press, released their latest video discussing HDR monitors. Are you ready to upgrade, and more importantly, should you?
High dynamic range (HDR) monitors are all the rage, but what exactly is HDR and which monitors produce the best image quality? Check out our full HDR guide: …
We produce videos for all our Raspberry Pi Press publications, including magazines such as The MagPi and HackSpace magazine, as well as our book releases, such as Code the Classics and Build Your Own First-Person Shooter in Unity.
Subscribe to the Raspberry Pi Press YouTube channel today and click on the bell button to ensure you’re notified of all new releases. And, for our complete publication library, visit the Raspberry Pi Press online store.
The post Wireframe’s deep(ish) dive into the glorious double jump appeared first on Raspberry Pi.
From last year’s issue 29 of Wireframe magazine: learn how to create your own version of the simple yet addictive side-scroller Flappy Bird. Raspberry Pi’s Rik Cross shows you how.
Flappy Bird: ridiculously big in 2014, at least for a while.
Flappy Bird was released by programmer Dong Nguyen in 2013, and made use of a straightforward game mechanic to create an addictive hit. Tapping the screen provided ‘lift’ to the main character, which is used strategically to navigate through a series of moving pipes. A point is scored for each pipe successfully passed. The idea proved so addictive that Nguyen eventually regretted his creation and removed it from the Google and Apple app stores. In this article, I’ll show you how to recreate this simple yet time-consuming game, using Python and Pygame Zero.
The player’s motion is very similar to that employed in a standard platformer: falling down towards the bottom of the screen under gravity. See the article, Super Mario-style jumping physics in Wireframe #7 for more on creating this type of movement. Pressing a button (in our case, the
SPACE bar) gives the player some upward thrust by setting its velocity to a negative value (i.e. upwards) larger than the value of gravity acting downwards. I’ve adapted and used two different images for the sprite (made by Imaginary Perception and available on opengameart.org), so that it looks like it’s flapping its wings to generate lift and move upwards.
Pressing the SPACE bar gives the bird ‘lift’ against gravity, allowing it to navigate through moving pipes.
Sets of pipes are set equally spaced apart horizontally, and move towards the player slowly each frame of the game. These pipes are stored as two lists of rectangles,
bottom_pipes, so that the player can attempt to fly through gaps between the top and bottom pipes. Once a pipe in the
top_pipes list reaches the left side of the screen past the player’s position, a
score is incremented and the top and corresponding bottom pipes are removed from their respective lists. A new set of pipes is created at the right edge of the screen, creating a continuous challenge for the player. The y-position of the gap between each newly created pair of pipes is decided randomly (between minimum and maximum limits), which is used to calculate the position and height of the new pipes.
The game stops and a ‘Game over’ message appears if the player collides with either a pipe or the ground. The collision detection in the game uses the
player.colliderect() method, which checks whether two rectangles overlap. As the player sprite isn’t exactly rectangular, it means that the collision detection isn’t pixel-perfect, and improvements could be made by using a different approach. Changing the values for
GRAVITY, PIPE_GAP, PIPE_SPEED, and
player.flap_velocity through a process of trial and error will result in a game that has just the right amount of frustration! You could even change these values as the player’s score increases, to add another layer of challenge.
If you’d like to read older issues of Wireframe magazine, you can find the complete back catalogue as free PDF downloads.
The latest issue of Wireframe is available in print to buy online from the Raspberry Pi Press store, with older physical issues heavily discounted too. You can also find Wireframe at local newsagents, but we should all be staying home as much as possible right now, so why not get your copy online and save yourself the trip?
The post Recreate Flappy Bird’s flight mechanic | Wireframe #29 appeared first on Raspberry Pi.
In this blog post, I want to share an update on how the Raspberry Pi Foundation is responding to the novel coronavirus and what it means for our work to support people all over the planet to change their world through technology.
The situation is changing rapidly, and we’ll update this blog as our response develops.
Update: on this web page, you will find advice we’ve collected from the community on how to continue engaging with your Code Club, CoderDojo, or Raspberry Jam members.
The main guidance to our teams, partners, and community members is that they should follow the local public health advice in the country or region where they are based.
The spread of the virus is at different stages in different parts of the world. That’s one reason why the public health advice differs so much depending on where you are. This is a new threat and there are competing theories about the best course of action. We see that in the different approaches that are being taken by different governments around the world.
To state what I am sure is obvious, we aren’t epidemiologists or public health experts. That’s why our approach is to follow the local public health advice.
We’ve been working closely with venues, partners, sponsors, and community members to keep our programme of events under review. There aren’t currently any restrictions on events that affect the specific dates and places where our events are being held. The problem really is one of uncertainty.
Until now, we’ve taken a ‘wait and see’ approach for events, following the local public health guidance closely and working on the assumption that we will go ahead as planned, unless the local advice is to cancel. However, over the past couple of days, we have become increasingly concerned that we are asking people to book travel and make practical arrangements when we think that there is a high likelihood that we will have to cancel events at the last minute.
We have therefore taken a number of very difficult decisions about our events programme.
We have decided to hold the Research Symposium as an online-only event. Plans for this are well developed, and we are looking forward to bringing together an amazing community of researchers, academics, and practitioners to discuss cutting-edge research on how young people learn computing and computer science. Registration remains open and we will provide updates on the event via the symposium web page.
We have decided to cancel both upcoming Coolest Projects events. This was a really tough decision. In both cases, there is just too much uncertainty for us to continue to ask young people, parents, mentors, and volunteers to make travel and other arrangements. We are exploring options for providing an online experience that will enable the young creators to still showcase their amazing projects, so please don’t stop work on your project. We will provide further updates on the Coolest Projects website.
We have issued guidance to the tens of thousands of brilliant human beings that organise Code Clubs, CoderDojos, Raspberry Jams, and other community-led events all over the world. Our message is that they should follow the local public health advice in their country or region and take decisions on whether to cancel their club or event in consultation with the venues that host them. If you are a club leader or an event organiser and you have a concern, please contact us in the usual way, or email us at email@example.com.
We are working with community members and partners to increase our support for online learning, and we are collecting guidance for the community on this web page. For now, clubs (and everyone else) can access all of our free learning resources online as usual.
As a organisation with a global supply chain that makes and sells products all over the world, we have been working with our partners to minimise the impact of the pandemic on the availability of our products, and on the wellbeing of those involved in our supply chain and distribution network. At this stage, I am delighted to report that Raspberry Pi products are still available in all of the usual places and we’re working very hard to make sure that this continues.
We have implemented a range of actions to support our colleagues wherever they work. This has included restricting non-essential international travel, encouraging and supporting flexible and home working, improving the cleaning and hygiene facilities at our offices, and putting in place extra support for colleagues who have increased caring responsibilities because of government or other institutions taking actions to control the spread of the virus, like school closures.
We are following local public health guidance on self-isolation and, for anyone who is unwell, we will provide sick pay as normal. We have committed that none of our employees will be out of pocket because of actions we take to prevent the spread of the virus.
We have encouraged colleagues to consider moving face to face meetings online, including job interviews. So if you’re due to meet anyone at the Foundation, they’ll check in with you about your preferences and agree the best approach with you.
One of the best things about Raspberry Pi is the amazing community that we have the privilege to work with everyday. That includes our teams, partners and funders, educators, volunteers, businesses, and millions of incredible young digital makers.
Whatever happens over the coming days, weeks, and months, it feels increasingly likely that everyone in this community will be affected in some way. Hopefully, for most people that will be nothing more than being inconvenienced.
Personally, I am finding the uncertainty one of the hardest things to deal with. I’ve really appreciated all of the messages of support and offers of help that I’ve received over the past few days. This has always been an organisation and a community where people genuinely care about and support each other. Let’s all double down on that now.
CEO Raspberry Pi Foundation
The post How the Raspberry Pi Foundation is responding to the novel coronavirus appeared first on Raspberry Pi.
Code the map and movement basics of the innovative marble-rolling arcade game. Mark Vanstone shows you how.
Each of Marble Madness’ six levels got progressively harder to navigate and had to be completed within a time limit.
Hitting arcades in 1984, Atari’s Marble Madness presented a rather different control mechanism than other games of the time. The original arcade cabinet provided players with a trackball controller rather than a conventional joystick, and the aim was to guide a marble through a three-dimensional course in the fastest possible time. This meant that a player could change the angle and speed of the marble as it rolled and avoid various obstacles and baddies.
During development, designer Mark Cerny had to shelve numerous ideas for Marble Madness, since the hardware just wasn’t able to achieve the level of detail and interaction he wanted. The groundbreaking 3D display was one idea that made it through to the finished game: its pre-rendered, ray-traced isometric levels.
Marble Madness was the first game to use Atari’s System 1 upgradeable hardware platform, and also boasted the first use of an FM sound chip produced by Yamaha to create its distinctive stereo music. The game was popular in arcades to start with, but interest appeared to drop off after a few months – something Cerny attributed to the fact that the game didn’t take long to play. Marble Madness’s popularity endured in the home market, though, with ports made for most computers and consoles of the time – although inevitably, most of these didn’t support the original’s trackball controls.
In our sample level, you can control the movement of the marble using the left and right arrow keys.
For our version of Marble Madness, we’re going to use a combination of a rendered background and a heightmap in Pygame Zero, and write some simple physics code to simulate the marble rolling over the terrain’s flats and slopes. We can produce the background graphic using a 3D modelling program such as Blender. The camera needs to be set to Orthographic to get the forced perspective look we’re after. The angle of the camera is also important, in that we need an X rotation of 54.7 degrees and a Y rotation of 45 degrees to get the lines of the terrain correct. The heightmap can be derived from an overhead view of the terrain, but you’ll probably want to draw the heights of the blocks in a drawing package such as GIMP to give you precise colour values on the map.
The ball rolling physics are calculated from the grey-shaded heightmap graphic. We’ve left a debug mode in the code; by changing the debug variable to
True, you can see how the marble moves over the terrain from the overhead viewpoint of the heightmap. The player can move the marble left and right with the arrow keys – on a level surface it will gradually slow down if no keys are pressed. If the marble is on a gradient on the heightmap, it will increase speed in the direction of the gradient. If the marble hits a section of black on the heightmap, it falls out of play, and we stop the game.
That takes care of the movement of the marble in two dimensions, but now we have to translate this to the rendered background’s terrain. The way we do this is to translate the Y coordinate of the marble as if the landscape was all at the same level – we multiply it by 0.6 – and then move it down the screen according to the heightmap data, which in this case moves the marble down 1.25 pixels for each shade of colour. We can use an overlay for items the marble always rolls behind, such as the finish flag. And with that, we have the basics of a Marble Madness level.
We use the image module from Pygame to sample the colour of the pixel directly under the marble on the heightmap. We also take samples from the left diagonal and the right diagonal to see if there is a change of height. We are only checking for left and right movement, but this sample could be expanded to deal with the two other directions and moving up the gradients, too. Other obstacles and enemies can be added using the same heightmap translations used for the marble, and other overlay objects can be added to the overlay graphic.
You can read more features like this one in Wireframe issue 34, available now at Tesco, WHSmith, all good independent UK newsagents, and the Raspberry Pi Store, Cambridge.
Or you can buy Wireframe directly from Raspberry Pi Press — delivery is available worldwide. And if you’d like a handy digital version of the magazine, you can also download issue 34 for free in PDF format.
Part of our work in the consortium behind the National Centre for Computing Education (NCCE) is to produce free classroom resources for teachers to deliver the Computing curriculum to students aged 5–16 in England. Our Director of Educator Support Carrie Anne Philbin describes how we define and represent progression in these resources.
For our work to develop a complete bank of free teaching resources that help teachers deliver the Computing curriculum in England, we knew that a strong progression framework is absolutely crucial. A progression framework is the backbone of any subject curriculum: it defines the sequence in which students learn, noting where core understanding of a topic is established in order to progress.
We studied a lot of progression frameworks, examination specifications, and even some research papers. What we found is that there are two quite different ways of presenting progression that show what should be taught and when it should be taught, as well as information on how or why concepts should be taught.
Firstly, there is the approach of creating a categorisation of skills and concepts into a list or table. Sequencing is shown by having objectives listed by Key Stage, year group, or even by learners’ age. Examples of this approach include the CAS computing progression pathways and the Massachusetts Digital Literacy and Computer Science Curriculum Framework. They are essentially lists of required knowledge that’s bundled by theme.
Another approach is to use a map of possible trajectories through learning waypoints and importantly how they connect to each other. This approach highlights where prerequisite knowledge needs to be mastered before students can move on, as well as the dependent knowledge contained in other nodes that need to be mastered in order to progress.
Cambridge Mathematics are leading the way in “developing a flexible and interconnected digital Framework to help reimagine mathematics education 3-19”. We’ve been lucky enough to learn from their work, which has helped us to create learning graphs.
For our free classroom resources, we organise computing content (concepts, knowledge, skills, and objectives) into interconnected networks we call learning graphs. We found that nodes often form clusters corresponding to specific themes, and we can connect them if they represent two adjacent waypoints in the learning process. Depending on the level of abstraction, the nodes in a learning graph contain anything ranging from the contents of a curriculum strand across an entire Key Stage, to the learning objectives of a six-lesson unit.
The learning graph for the Year 9 unit ‘Representations: going audiovisual’. Click to embiggen.
Initially, the graphs we produce are in a fluid state: they uncover the structure of the content and the possible journeys through it, without being bound to a specific teaching pathway. As we develop the content further, the graphs eventually reach a solid state, where the nodes are arranged to reflect our suggestions on the order in which teachers could actually deliver the content.
We believe that learning graphs are useful to teachers on a whole new level: they directly inform lesson planning, but they also add value by showing opportunities to assess understanding at landmark waypoints in a lesson or unit. By checking that students are grasping the concepts, teachers are able to think more about how they are teaching and can revisit knowledge that perhaps didn’t land with learners the first time.
All progression frameworks are subjective, and because so far there’s only little research into computing education, we rely on teachers’ experience of combining the ‘what’ we teach and ‘how’ to teach it in order to help inform this work. If you’ve not taken a look at our learning graphs for the NCCE Resource Repository, access them via teachcomputing.org/resources and let us know your thoughts via firstname.lastname@example.org.
A version of this article will be part of the upcoming issue of Hello World, our free magazine for computing educators, launching on 23 March. Follow Hello World on Twitter for updates!
The post Our approach to developing progression for teaching computing appeared first on Raspberry Pi.
The Edwards Lab at the University of Reading has developed a flexible, low-cost, open source lab robot for capturing images of microbiology samples with a Raspberry Pi camera module. It’s called POLIR, for Raspberry Pi camera Open-source Laboratory Imaging Robot. Here’s a timelapse video of them assembling it.
The robot is useful for all kinds of microbiology imaging, but at the moment the lab is using it to measure antimicrobial resistance in bacteria. They’re doing this by detecting the colour change in a dye called resazurin, which changes from blue to pink in the presence of metabolically active cells: if bacteria incubated with antibiotics grow, their metabolic activity causes the dye to turn pink. However, if the antibiotics stop or impede the growth of the bacteria, their lower levels of metabolic activity will cause less colour change, or none at all. In the photo below, the colourful microtitre plate holds bacterial samples with and without resistance to the antibiotics against which they’re being tested.
POLIR, an open source 3D printer-based Raspberry Pi lab imaging robot
The researchers adapted existing open source 3D printer designs and used v-slot aluminium extrusion (this stuff) with custom 3D-printed joints to make a frame. Instead of a printer extrusion head, a Raspberry Pi and camera module are mounted on the frame. An Arduino running open-source Repetier software controls x-y-z stepper motors to adjust the position of the computer and camera.
Front and top views of POLIR
Open-source OctoPrint software controls the camera position by supplying scripts from the Raspberry Pi to the Arduino. OctoPrint also allows remote access and control, which gives researchers flexibility in when they run experiments and check progress. Images are acquired using a Python script configured with the appropriate settings (eg image exposure), and are stored on the Raspberry Pi’s SD card. From there, they can be accessed via FTP.
Off-the-shelf lab automation systems are extremely expensive and remain out of the reach of most research groups. POLIR cost just £600.
The system has a number of advantages over higher-cost off-the-shelf imaging systems. One is its flexibility: the robot can image a range of sample formats, including agar plates like those in the video above, microtitre plates like the one in the first photograph, and microfluidic “lab-on-a-comb” devices. A comb looks much like a small, narrow rectangle of clear plastic with striations running down its length; each striation is a microcapillary with capacity for a 1μl sample, and each comb has ten microcapillaries. These microfluidic devices let scientists run experiments on a large number of samples at once, while using a minimum of space on a lab bench, in an incubator, or in an imaging robot like POLIR.
POLIR accommodates 2160 individual capillaries and a 96 well plate, with room to spare
For lab-on-a-comb images, POLIR gives the Reading team four times the spatial resolution they get with a static camera. The moveable Raspberry Pi camera with a short focus yields images with 6 pixels per capillary, compared to 1.5 pixels per capillary using a $700 static Canon camera with a macro lens.
Because POLIR is automated, it brings higher temporal resolution within reach, too. A non-automated system, by contrast, can only be used for timelapse imaging if a researcher repeatedly intervenes at fixed time intervals. Capturing kinetic data with timelapse imaging is valuable because it can be significant if different samples reach the same endpoint but at different rates, and because some dyes can give a transient signal that would be missed by an endpoint measurement alone.
Dr Alexander Edwards of the University of Reading comments:
We built the robot with a simple purpose, to make antimicrobial resistance testing more robust without resorting to expensive and highly specialised lab equipment […] The beauty of the POLIR kit is that it’s based on open source designs and we have likewise published our own designs and modifications, allowing everyone and anyone to benefit from the original design and the modifications in other contexts. We believe that open source hardware is a game changer that will revolutionise microbiological and other life science lab work by increasing data production whilst reducing hands-on labour time in the lab.
You can find POLIR on GitLab here. You can also read more, and browse more figures, in the team’s open-access paper, Exploiting open source 3D printer architecture for laboratory robotics to automate high-throughput time-lapse imaging for analytical microbiology.
The post Raspberry Pi vs antibiotic resistance: microbiology imaging with open source hardware appeared first on Raspberry Pi.
Here’s our latest How to use video, showing you how to connect a button to your Raspberry Pi.
Learn how to use a tactile button with your Raspberry Pi. They’re a great addition to any digital making project! Subscribe to our YouTube channel: http://rp…
Attaching a button to your Raspberry Pi is a great way of introducing digital making into your coding experience. Use it to play music, turn lights on and off, or even shut down your device.
Follow our other How to use videos to learn how to use a servo motor, LED, and Raspberry Pi camera module with your Raspberry Pi. Try linking them together to build something grander, such as a digital camera, a robot, or a music box.
People make marvellous things for their pets with Raspberry Pi. Here’s a splendid hamster feeder tutorial from Christopher Barnatt of Explaining Computers, just perfect if you’re after a small project for this weekend.
Raspberry Pi servo-controlled pet feeder, using a Raspberry Pi Zero and two SG90 servo motors. This project builds on the servo control code and setup from m…
All you need to build your hamster feeder is a Raspberry Pi Zero and peripherals, a couple of servos, some plasticard, sellotape and liquid polyadhesive, and some jumper wires. The video takes you very clearly through the entire set-up, from measurements to wiring details to Python code (which is available to download). As Christopher explains, this will allow you to feed your hamster controlled portions of food at suitable intervals, so that it doesn’t eat the lot in one go and, consequently, explode. What’s not to love?
Check out the Explaining Computers YouTube channel for more clear, detailed videos to help you do more with computing. And for more Raspberry Pi projects, head to our own Raspberry Pi projects, with hundreds of ideas for beginners and beyond available in English and many other languages.
We’ve made a simpler way to image your microSD card with Raspbian, the official Raspberry Pi operating system, and other operating systems. Introducing our new imaging utility, Raspberry Pi Imager.
For me, one of the most important aspects of the Raspberry Pi experience is trying to make it as easy as possible to get started. To this end, since launching the first Raspberry Pi, we’ve added a GUI to our operating system, a wizard to help you set up your Raspberry Pi the first time you boot it, and lots of books and magazines to get people up and running. We’ve even developed the Raspberry Pi Desktop Kit to put all the things you need (yes, Alex, I know – except for a monitor) into a single box to make it as easy as possible!
Despite all these moves towards more simplicity, when it comes to microSD cards, programming them with your favourite Raspberry Pi operating system has always been a little bit tricky.
The main problem comes from the differences between the operating systems that people’s main computers are likely to use: Windows, macOS, and Linux all use different methods of accessing the SD card, which doesn’t help matters. And, for some new Raspberry Pi users, understanding where to find the latest up-to-date image and how to get it onto the microSD card can be a bit confusing, unless you’ve had prior experience with image-flashing tools such as Etcher.
For that reason, we’ve always suggested that you should buy a pre-loaded NOOBS SD card from your Raspberry Pi Approved Reseller.
But what if you want to re-image an existing card?
From today, Raspberry Pi users will be able to download and use the new Raspberry Pi Imager, available for Windows, macOS and Ubuntu.
The utility is simple to use and super speedy, thanks to some shortcuts we’ve introduced into the mechanics.
Firstly, Raspberry Pi Imager downloads a .JSON file from our website with a list of all current download options, ensuring you are always installing the most up-to-date version.
Once you’ve selected an operating system from the available options, the utility reads the relevant file directly from our website and writes it straight to the SD card. This speeds up the process quite considerably compared to the standard process of reading it from the website, writing it to a file on your hard drive, and then, as a separate step, reading it back from the hard drive and writing it to the SD card.
During this process, Raspberry Pi Imager also caches the downloaded operating system image – that is to say, it saves a local copy on your computer, so you can program additional SD cards without having to download the file again.
Download the Raspberry Pi Imager from our downloads page today.
Raspberry Pi Imager is fully open source and was originally written as a modification of the PiBakery tool, later modified and finished by Floris Bos (the original writer of the NOOBS tool and the PiServer tool). You can see Floris’ other software, for data centres, here.
The post Introducing Raspberry Pi Imager, our new imaging utility appeared first on Raspberry Pi.
Since we first launched Raspberry Pi, an SD card (or microSD card) has always been a vital component. Without an SD card to store the operating system, Raspberry Pi is pretty useless*! Over the ensuing eight years, SD cards have become the default removable storage technology, used in cameras, smartphones, games consoles and all sorts of other devices. Prices have plummeted to the point where smaller size cards are practically given away for free, and at the same time storage capacity has increased to the point where you can store a terabyte on your thumbnail.
However, the fact that SD cards are now so commonplace sometimes conceals the fact that not all SD cards are created equal. SD cards have a speed rating – how fast you can read or write data to the card – and as card sizes have increased, so have speed ratings. If you want to store 4K video from your digital camera, it is important not just that the card is big enough to hold it, but also that you can write it to the card fast enough to keep up with the huge amount of data coming out of the camera.
The speed of an SD card will also directly affect how fast your Raspberry Pi runs, in just the same way as the speed of a hard drive affects how fast a conventional desktop computer runs. The faster you can read data from the card, the faster your Raspberry Pi will boot, and the faster programs will load. Equally, write speed will also affect how well any programs which save large quantities of data run – so it’s important to use a good-quality card.
The speed rating of an SD card should be printed either on the card itself or on the packaging.
The 32GB card shown below is Class 4, denoted by the 4 inside the letter C – this indicates that it can write at 4MB/s.
The 64GB card shown below is Class 10, and so can write at 10MB/s. It also shows the logo of UHS (“ultra high speed”) Class 1, the 1 inside the letter U, which corresponds to the same speed.
More recently, speeds have started to be quoted in terms of the intended use of the card, with Class V10 denoting a card intended for video at 10MB/s, for example. But the most recent speed categorisation – and the one most relevant to use in a Raspberry Pi – is the new A (for “application”) speed class. We recommend the use of Class A1 cards (as the one above – see the A1 logo to the right of the Class 10 symbol) in Raspberry Pi – in addition to a write speed of 10MB/s, these support at least 1500 read operations and 500 write operations per second. All the official Raspberry Pi microSD cards we sell meet this specification.
We’ve all heard the stories of people who have bought a large capacity SD card at a too-good-to-be-true price from a dodgy eBay seller, and found that their card labelled as 64GB can only actually hold 2GB of data. But that is at least fairly easy to spot – it’s much harder to work out whether your supposedly fast SD card is actually meeting its specified speed, and unscrupulous manufacturers and sellers often mislabel low quality cards as having unachievable speeds.
Today, as the first part of a new suite of tests which will enable you to perform various diagnostics on your Raspberry Pi hardware, we are releasing a tool which allows you to test your SD card to check that it performs as it should.
To install the new tool, from a terminal do
sudo apt update sudo apt install agnostics
(“agnostics”? In this case it’s nothing to do with religion! I’ll leave you to work out the pun…)
Once installed, you will find the new application “Raspberry Pi Diagnostics” in the main menu under “Accessories”, and if you launch it, you’ll see a screen like this:
In future, this screen will show a list of the diagnostic tests, and you will be able to select which you want to run using the checkboxes in the right-hand column. But for now, the only test available is SD Card Speed Test; just press “Run Tests” to start it.
One thing to note is that the write performance of SD cards declines over time. A new card is blank and data can be written to what is effectively “empty” memory, which is fast; but as a card fills up, memory needs to be erased before it can be overwritten, and so writes will become slower the more a card is used. The pass / fail criteria in this test assume a new (or at least freshly formatted) card; don’t be alarmed if the write speed test fails when run on the SD card you’ve been using for six months! If you do notice your Raspberry Pi slowing down over time, it may be worth backing up your SD card using the SD Card Copier tool and reformatting it.
The test takes a minute or so to run on a Raspberry Pi 4 (it’ll take longer on older models), and at the end you’ll see a results screen with either (hopefully) PASS or (if you are less fortunate) FAIL. To see the detailed results of the speed test, press “Show Log”, which will open the test log file in a text editor. (The log file is also written to your home directory as rpdiags.txt.)
We are testing against the A1 specification, which requires a sequential write speed of 10MB/s, 500 random write operations per second, and 1500 random read operations per second; we run the test up to three times. (Tests of this nature are liable to errors due to other background operations accessing the SD card while the test is running, which can affect the result – by running the test multiple times we try to reduce the likelihood of a single bad run resulting in a fail.)
If the test result was a pass, great! Your SD card is good enough to provide optimum performance in your Raspberry Pi. If it failed, have a look in the log file – you’ll see something like:
Raspberry Pi Diagnostics - version 0.1 Mon Feb 24 09:44:16 2020 Test : SD Card Speed Test Run 1 prepare-file;0;0;12161;23 seq-write;0;0;4151;8 rand-4k-write;0;0;3046;761 rand-4k-read;9242;2310;0;0 Sequential write speed 4151 kb/s (target 10000) - FAIL Note that sequential write speed declines over time as a card is used - your card may require reformatting Random write speed 761 IOPS (target 500) - PASS Random read speed 2310 IOPS (target 1500) - PASS Run 2 prepare-file;0;0;8526;16 ...
You can see just how your card compares to the stated targets; if it is pretty close to them, then your card is only just below specification and is probably fine to use. But if you are seeing significantly lower scores than the targets, you might want to consider getting another card.
[*] unless you’re using PXE network or USB mass storage boot modes of course.
If you read The MagPi, it’s safe to say you like making in some way. The hobby has exploded in popularity over the last few years, thanks in no small part to a burgeoning online community and the introduction of low-cost computing with Raspberry Pi.
Last year we decided to celebrate making with a month-long online event called #MonthOfMaking. The idea was simply to get people to share what they’re making online, whatever it was. Whether you’re turning on your first LED with code or sending rockets to the moon, we want to create a space where you can share your proud achievements. So, let’s get making.
#MonthOfMaking is simply an excuse to get people inspired to make something. And by make, we mean electronics, engineering, art, and craft projects. Get your creative powers buzzing and make something that you can show to the world.
There’s no skill-level threshold to participating either. If you’ve been wanting to start learning, this can be your jumping-on point. By sharing your builds with the community, you can learn and grow. Here are some simple rules to sum it all up:
We’ve all been there. Sat down at a work bench or desk, staring at some components and thinking… what can I make with this? What would I like to make? Like any other creative pursuit, you’ll need some inspiration. If the projects in the magazine haven’t inspired you, then here are some website suggestions…
Instructables is one of the oldest sites out there for finding amazing project guides and ideas, and we’ve been fans of it for years. The best part is you can search by specific project types as well, including Raspberry Pi if you’d like to keep it on‑brand. They’ve recently added more arts and crafts stuff if you fancy trying your hand at knitting.
For more serious hacks for more advanced makers, Hackaday and Hackster have some great projects that really take a deep dive into a project. If you’re curious as to the limits of electronics and programming, these may be the place to look. Equally, if you want to do something huge with a lot of computer power, they should be your first stop.
There are so many amazing things on the Raspberry Pi projects site that can help you with your first steps in just about any field of making. It’s also home to loads of great and simple home-grown projects that are perfect for young makers and older makers alike.
Step 01 Read and understand
Basing your build on a tutorial you’ve seen? Seen a few things you’d like to combine into something else? Always make sure to read the instructions you’ve found properly so that you know if it’s within your skill level.
Step 02 Order supplies
Write a list of what you need. Always double‑check you have the component you think you have. Sometimes you may need to buy from separate places, so just make sure the delivery times work for you.
Step 03 Follow along and be safe
Need adult supervision for a project? Absolutely get some. Even adults need to be wary, so always take safety precautions and wear protective clothing when needed. Make sure to follow any tutorials you’ve found as closely as you can.
The rest of our #MonthOfMaking guide, along with loads more amazing projects and tutorials, can be found in The MagPi #91, out today, including our starter electronics guide! You can get The MagPi #91 online at our store, or in print from the Raspberry Pi Store in Cambridge and all good newsagents and supermarkets. You can also access The MagPi magazine via our Android and iOS apps.
We have a new US subscription offer!
Don’t forget our amazing subscription offers, which include a free gift of a Raspberry Pi Zero W when you subscribe for twelve months. Until the end of March, you can get a twelve-month subscription in the US for only $60! Head to magpi.cc/usa to find out more.
And, as with all our Raspberry Pi Press publications, you can download the free PDF from our website.
Fly through the space fortress in this 3D retro forced scrolling arcade sample. Mark Vanstone has the details
Zaxxon was the first arcade game to use an axonometric viewpoint, which made it look very different from its 2D rivals.
When Zaxxon was first released by Sega in 1982, it was hailed as a breakthrough thanks to its pseudo-3D graphics. This axonometric projection ensured that Zaxxon looked unlike any other shooter around in arcades.
Graphics aside, Zaxxon offered a subtly different twist on other shooting games of the time, like Defender and Scramble; the player flew over either open space or a huge fortress, where they had to avoid obstacles of varying heights. Players could tell how high they were flying with the aid of an altimeter, and also the shadow beneath their ship (shadows were another of Zaxxon’s innovations). The aim of the game was to get to the end of each level without running out of fuel or getting shot down; if the player did this, they’d encounter an area boss called Zaxxon. Points were awarded for destroying gun turrets and fuel silos, and extra lives could be gained as the player progressed through the levels.
Our Zaxxon homage running in Pygame Zero: fly the spaceship through the fortress walls and obstacles with your cursor keys.
For this code sample, we can borrow some of the techniques used in a previous Source Code article about Ant Attack (see Wireframe issue 15) since it also used an isometric display. Although the way the map display is built up is very similar, we’ll use a JSON file to store the map data. If you’ve not come across JSON before, it’s well worth learning about, as a number of web and mobile apps use it, and it can be read by Python very easily. All we need to do is load the JSON file, and Python automatically puts the data into a Python dictionary object for us to use.
In the sample, there’s a short run of map data 40 squares long with blocks for the floor, some low walls, higher walls, and a handful of fuel silos. To add more block types, just add data to the
blocktypes area of the JSON file. The codes used in the map data are the index numbers of the
blocktypes, so the first
index 0, the next
index 1, and so on. Our
drawMap() function takes care of rendering the data into visual form and blits blocks from the top right to the bottom left of the screen. When the
draw loop gets to where the ship is, it draws first the shadow and then the ship a little higher up the screen, depending on the altitude of the ship. The equation to translate the ship’s screen coordinates to a block position on the map is a bit simplistic, but in this case, it does the job well enough.
Cursor keys guide the movement of the spaceship, which is limited by the width of the map and a height of 85 pixels. There’s some extra code to display the ship if it isn’t on the map – for example, at the start, before it reaches the map area. To make the code snippet into a true Zaxxon clone, you’ll have to add some laser fire and explosions, a fuel gauge, and a scoring system, but this code sample should provide the basis you’ll need to get started.
You can read more features like this one in Wireframe issue 33, available now at Tesco, WHSmith, all good independent UK newsagents, and the Raspberry Pi Store, Cambridge.
Or you can buy Wireframe directly from Raspberry Pi Press — delivery is available worldwide. And if you’d like a handy digital version of the magazine, you can also download issue 33 for free in PDF format.
The post Code a Zaxxon-style axonometric level | Wireframe #33 appeared first on Raspberry Pi.
Happy birthday to us: tomorrow marks the eighth birthday of the Raspberry Pi computer!
On 29 February 2012 we launched our very first $35 credit card-sized computer, Raspberry Pi 1 Model B. Since then, we’ve sold over 30 million Raspberry Pi computers worldwide. People all over the world (and beyond!) use them to learn, teach, and make cool stuff; industrial customers embed Raspberry Pi devices in their own products or use them to monitor and control factory processes. As an early birthday present, yesterday we cut the price of the 2GB RAM Raspberry Pi 4 Model B from $45 to $35: now you can buy a no-compromises desktop PC for the same price as Raspberry Pi 1 in 2012.
Don’t try this at home: you may damage your Raspberry Pi or teeth.
Throughout the last eight years, a passionate community of enthusiasts has championed the use of Raspberry Pi, and our library of free resources, by hosting Raspberry Jams: events where people of all ages come together to learn about digital making in a fun, friendly, and inclusive environment.
To celebrate Raspberry Pi’s in style, Raspberry Jam community members around the world are hosting special birthday-themed events during the whole month from 15 February to 15 March.
Our special thanks to The Pi Hut for shipping our special birthday packs to these Jams all over the world!
The contents of the packs we sent to Raspberry Jams that registered events during our birthday month. Thanks for the photo go to Andy Melder, who runs Southend and Chelmsford Raspberry Jams.
20 Birthday Jams have already taken place in Australia, Belgium, Bulgaria, Canada, Greece, India, the UK, and the US. In total, there are at least 118 Birthday Jam events across 35 countries on 6 continents this year! (We’re determined to reach Antarctica one day soon.)
Jams can take many forms, from talks and workshops based around the Raspberry Pi computer, to project showcases and hackathons. Here is a selection of photos from some of the birthday events community members have run over the last fortnight:
We’d like to give a special mention to Masafumi Ohta and our friends at Tokyo Raspberry Jam, who have had to postpone their Birthday Jam due to coronavirus-related safety restrictions currently in place across Japan.
The Birthday Jam in Tokyo in 2018
The whole team at the Foundation sends their best wishes to everyone who is affected by the virus!
Jam makers are running birthday events up to and including 15 March, so check out the Raspberry Jam world map to find your nearest Birthday Jam!
Chelmsford Raspberry Jam, celebrating Raspberry Pi’s eighth birthday with multiple generations
It’s really simple to register your Birthday Jam: just fill in the Raspberry Jam submission form, including a valid event information URL linking to a webpage with more information about your event. (This is an excellent example of a Jam event listing.)
As always, if you have any questions, please don’t hesitate to ask us via email@example.com.
The post Raspberry Jams around the world celebrate Raspberry Pi’s 8th birthday appeared first on Raspberry Pi.
TL;DR: it’s our eighth birthday, and falling RAM prices have allowed us to cut the price of the 2GB Raspberry Pi 4 to $35. You can buy one here.
In two days’ time, it will be our eighth birthday (or our second, depending on your point of view). Many of you set your alarms and got up early on the morning of 29 February 2012, to order your Raspberry Pi from our newly minted licensee partners, RS Components and Premier Farnell. In the years since, we’ve sold over 30 million Raspberry Pi computers; we’ve seen our products used in an incredible range of applications all over the world (and occasionally off it); and we’ve found our own place in a community of makers, hobbyists, engineers and educators who are changing the world, one project, or one student, at a time.
Our very first website led with an early prototype running an Ubuntu 9.04 desktop
Every subsequent product – from quad-core Raspberry Pi 2 in 2015, to 64-bit Raspberry Pi 3 in 2016, to Raspberry Pi 3+ in 2018 – whittled down those compromises a little further. By offering steadily increasing processing power at a time when the performance of traditional PCs had begun to stagnate, we were gradually able to catch up with typical PC use cases. With each generation, more people were able to use a Raspberry Pi as their daily-driver PC.
Until, in June of last year, we launched Raspberry Pi 4. Roughly forty times faster than the original Raspberry Pi, for the first time we have a no-compromises PC for the majority of users. I’ve described Raspberry Pi 4 as “the Raspberry Pi I’d buy for my parents”, and since I bought them a Desktop Kit for Christmas they’ve found it to be basically indistinguishable in performance and functionality from other PCs.
In a sense, this was a “mission accomplished” moment. But Raspberry Pi 4 brought its own compromises: for the first time we couldn’t fit as much memory as we wanted into the base product. While the $35 1GB device makes a great media player, home server, or embedded controller, to get the best desktop experience you need at least 2GB of RAM. At launch this would have cost you $45.
Which brings us to today’s announcement. The fall in RAM prices over the last year has allowed us to cut the price of the 2GB variant of Raspberry Pi 4 to $35. Effective immediately, you will be able to buy a no-compromises desktop PC for the same price as Raspberry Pi 1 in 2012. In comparison to that original machine, we offer:
And of course, thanks to inflation, $35 in 2012 is equivalent to nearly $40 today. So effectively you’re getting all these improvements, and a $5 price cut.
We’re going to keep working to make Raspberry Pi a better desktop computer. But this feels like a great place to be, eight years in. We hope you’ve enjoyed the first eight years of our journey as much as we have: here’s to another eight!
In line with our commitment to long-term support, the 1GB product will remain available to industrial and commercial customers, at a list price of $35. As there is no price advantage over the 2GB product, we expect most users to opt for the larger-memory variant.
The 4GB variant of Raspberry Pi 4 will remain on sale, priced at $55.
Day three of our Pong celebration leads us here, to HackSpace magazine’s ultrasonic hack of Eben’s Code the Classics Pong tribute, Boing!
If you haven’t yet bought your copy of Code the Classics, you have until 11:59pm GMT tonight to get £1 off using the discount code PONG. Click here to visit the Raspberry Pi Press online store to secure your copy, and read on to see how you can use ultrasonic sensors to turn this classic game into something a lot more physical.
Over to the HackSpace magazine team…
Code the Classics is an entertaining book for a whole bunch of reasons, but one aspect of it that is particularly exciting to us makers is that it means there are some games out there that are really fun to play, but also written to be easy to understand and have high-quality game art to go along with them. Why does this excite us as makers? Because it makes them ideal candidates for testing out novel DIY games controllers!
We’re going to start right at the beginning of the book (and also at the beginning of computer game history) with the game Pong. There’s a great chapter on this seminal game in the book, but we’ll dive straight into the source code of our Boing! tribute game. This code should run on any computer with Python 3 (and a few dependencies) installed, but we’ll use a Raspberry Pi, as this has GPIO pins that we can use to add on our extra controller.
Download the code here by clicking the ‘Clone or download’ button, and then ‘Download ZIP’. Unzip the downloaded file, and you should have a directory called
Code‑The‑Classics-master, and inside this, a directory called
Open a terminal and navigate to this directory, then run:
If everything works well, you’ll get a screen asking you to select one or two players – press SPACE to confirm your selection, and have a play.
So that’s how Eben Upton designed the game to be played. Let’s put our own spin on it. Games controllers are basically just sensors that take input from the real world in some way and translate that into in-game actions. Most commonly, these sensors are buttons that you press, but there’s no need for that to be the case. You can use almost any sensor you can get input from – it sounds trite, but the main limitation really is your imagination!
We were playing with ultrasonic distance sensors in the last issue of HackSpace magazine, and this sprung to mind a Pong controller. After all, distance sensors measure in one dimension and Pong bats travel in one dimension.
Last issue we learned that the main challenge when using the cheap HC-SR04 sensors with 3.3V devices is that they use 5V, so we need to reduce their output to 3.3V. A simple voltage divider does the trick, and we used three 330Ω resistors to achieve this – see Figure 1 for more details.
There’s support for these sensors in the GPIO Zero Python library. As a simple test, you can obtain the distance with the following Python code:
import gpiozero import time sensor = gpiozero.DistanceSensor(echo=15,trigger=14) while True: print(sensor.distance) time.sleep(0.1)
That will give you a constant read-out of the distance between the ultrasonic sensor and whatever object is in front of it. If you wave your hand around in front of the sensor, you’ll see the numbers changing from 0 to 1, which is the distance in metres.
So far, so straightforward. We only need to add a few bits to the code of our Boing! game to make it interact with the sensor. You can download an updated version of Boing! here, but the changes are as follows.
Add this line to the import statements at the top:
Add this line to instantiate the distance sensor object at the end of the file (just before
p1_distance = DistanceSensor(echo=15,trigger=14,queue_len=5)
We added the queue_len parameter to get the distances through a little quicker.
Finally, overwrite the p1_controls function with the following:
def p1_controls(): move = 0 distance = p1_distance.distance print(distance) if distance < 0.1: move = PLAYER_SPEED elif distance > 0.2: move = -PLAYER_SPEED return move
This uses the rather arbitrary settings of 10 cm and 20 cm to define whether the paddle moves up or down. You can adjust these as required.
That’s all there is to our ultrasonic Pong. It’s great fun to play, but there are, no doubt, loads of other versions of this classic game you can make by adding different sensors. Why not see what you can come up with?
Today is the last day to get £1 off Code the Classics with the promo code PONG, so visit the Raspberry Pi Press online store to order your discounted copy before 11:59pm GMT tonight.
You can also download Code the Classics as a free PDF here, but the book, oh, the book – it’s a marvellous publication that deserves a physical presence in your home.
The post Play Pong with ultrasonic sensors and a Raspberry Pi | HackSpace magazine appeared first on Raspberry Pi.
Following on from yesterday’s introduction to Pong, we’re sharing Boing!, the Python-based tribute to Pong created by Eben Upton exclusively for Code the Classics. Read on to get a detailed look at the code for Boing!
You can find the download link for the Boing! code in the Code the Classics book, available now in a variety of formats. Be sure to stick with today’s blog post until the end, for a special Code the Classics offer.
To show how a game like Pong can be coded, we’ve created Boing! using Pygame Zero, a beginner-friendly tool for making games in Python. It’s a good starting point for learning how games work – it takes place on a single screen without any scrolling, there are only three moving objects in the game (two bats and a ball), and the artificial intelligence for the computer player can be very simple – or even non-existent, if you’re happy for the game to be multiplayer only. In this case, we have both single-player and two-player modes.
The code can be divided into three parts. First, there’s the initial startup code. We import from other Python modules so we can use their code from ours. Then we check to make sure that the player has sufficiently up-to-date versions of Python and Pygame Zero. We set the
HEIGHT variables, which are used by Pygame Zero when creating the game window. We also create two small helper functions which are used by the code.
The next section is the largest. We create four classes:
Game. The first three classes inherit from Pygame Zero’s Actor class, which amongst other things keeps track of an object’s location in the game world, and takes care of loading and displaying sprites.
Ball define the behaviour of the corresponding objects in the game, while
Impact is used for an animation which is displayed briefly whenever the ball bounces off something. The
Game class’s job is to create and keep track of the key game objects, such as the two bats and the ball.
Further down, we find the
draw functions. Pygame Zero calls these each frame, and aims to maintain a frame rate of 60 frames per second. Gameplay logic, such as updating the position of an object or working out if a point has been scored, should go in
update, while in
draw we tell each of the Actor objects to draw itself, as well as displaying backgrounds, text, and suchlike.
draw functions make use of two global variables:
game. At any given moment, the game can be in one of three states: the main menu, playing the game, or the game-over screen. The
draw functions read the
state variable and run only the code relevant to the current state. So if
state is currently
State.MENU, for example,
update checks to see if the SPACE bar or the up/down arrows are pressed and updates the menu accordingly, and
draw displays the menu on the screen. The technical term for this kind of system is ‘finite state machine’.
The Game class’s job is to create and keep track of the key game objects
game variable references an instance of the
Game class as described above. The
__init__ (constructor) method of
Game optionally receives a parameter named
controls. When we create a new
Game object for the main menu, we don’t provide this parameter and so the game will therefore run in attract mode – in other words, while you’re on the main menu, you’ll see two computer-controlled players playing against each other in the background. When the player chooses to start a new game, we replace the existing
Game instance with a new one, initialising it with information about the controls to be used for each player – if the controls for the second player are not specified, this indicates that the player has chosen a single-player game, so the second will be computer-controlled.
In Boing!, the
Ball classes inherit from Pygame Zero’s Actor class, which provides a number of ways to specify an object’s position. In this game, as well as games in later chapters, we’re setting positions using the
y attributes, which by default specify where the centre of the sprite will be on the screen. Of course, we can’t just set an object’s position at the start and be done with it – if we want it to move as the game progresses, we need to update its position each frame. In the case of a
Bat, movement is very simple. Each frame, we check to see if the relevant player (which could be a human or the computer) wants to move – if they do, we either subtract or add 4 from the bat’s Y coordinate, depending on whether they want to move up or down. We also ensure that the bat does not go off the top or bottom of the screen. So, not only are we only moving along a single axis, our Y coordinate will always be an integer (i.e. a whole number). For many games, this kind of simple movement is sufficient. Even in games where an object can move along both the X and Y axes, we can often think of the movement along each axis as being separate. For example, in the next chapter’s game, Cavern, the player might be pressing the right arrow key and therefore moving along the X axis at 4 pixels per frame, while also moving along the Y axis at 10 pixels per frame due to gravity. The movement along each axis is independent of the other.
Able to move at any angle, the ball needs to move at the same speed regardless of its direction
Ball, things get a bit more complicated. Not only can it move at any angle, it also needs to move at the same speed regardless of its direction. Imagine the ball moving at one pixel per frame to the right. Now imagine trying to make it move at a 45° angle from that by making it move one pixel right and one pixel up per frame. That’s a longer distance, so it would be moving faster overall. That’s not great, and that’s before we’ve even started to think about movement in any possible direction.
The solution is to make use of vector mathematics and trigonometry. In the context of a 2D game, a vector is simply a pair of numbers: X and Y. There are many ways in which vectors can be used, but most commonly they represent positions or directions.
You’ll notice that the
Ball class has a pair of attributes,
dy. Together these form a vector representing the direction in which the ball is heading. If
dy are 1 and 0.5, then each time the ball moves, it’ll move by one pixel on the X axis and a half a pixel on the Y axis. What does it mean to move half a pixel? When a sprite is drawn, Pygame Zero will round its position to the nearest pixel. So the end result is that our sprite will move down the screen by one pixel every other frame, and one pixel to the right every frame (Figure 1).
We still need to make sure that our object moves at a consistent speed regardless of its direction. What we need to do is ensure that our direction vector is always a ‘unit vector’ – a vector which represents a distance of one (in this case, one means one pixel, but in some games it will represent a different distance, such as one metre). Near the top of the code you’ll notice a function named
normalised. This takes a pair of numbers representing a vector, uses Python’s
math.hypot function to calculate the length of that vector, and then divides both the X and Y components of the vector by that length, resulting in a vector which points in the same direction but has a length of one (Figure 2).
Vector maths is a big field, and we’ve only scratched the surface here. You can find many tutorials online, and we also recommend checking out the Vector2 class in Pygame (the library on top of which Pygame Zero is built).
Update Raspbian to try Boing! and other Code the Classics games on your Raspberry Pi.
The full BOING! tutorial, including challenges, further explanations, and a link to the downloadable code can be found in Code the Classics, the latest book from Raspberry Pi Press.
We’re offering £1 off Code the Classics if you order it before midnight tomorrow from the Raspberry Pi Press online store. Visit the store now, or use the discount code PONG at checkout if you make a purchase before midnight tomorrow.
As always, Code the Classics is available as a free PDF from the Wireframe website, but we highly recommend purchasing the physical book, as it’s rather lovely to look at and would make a great gift for any gaming and/or coding enthusiast.
One topic explored in Code the Classics from Raspberry Pi Press is the origin story and success of Pong, one of the most prominent games in early video game history.
‘The success of Pong led to the creation of Pong home consoles (and numerous unofficial clones) that could be connected to a television. Versions have also appeared on many home computers.’
Ask anyone to describe a game of table tennis and they’ll invariably tell you the same thing: the sport involves a table split into quarters, a net dividing the two halves, a couple of paddles, and a nice round ping-pong ball to bat back and forth between two players. Take a look at the 1972 video game Pong, however, and you’ll notice some differences. The table, for instance, is simply split in half and it’s viewed side-on, the paddles look like simple lines, and the ball is square. Yet no one – not even now – would have much trouble equating the two.
Back in the early 1970s, this was literally as good as it got. The smattering of low-powered arcade machines of the time were incapable of realistic-looking graphics, so developers had to be creative, hoping imaginative gamers would fill the gaps and buy into whatever they were trying to achieve. It helped enormously that there was a huge appetite for the new, emerging video game industry at that time. Nolan Bushnell was certainly hungry for more – and had he turned his nose up at Spacewar!, a space combat game created by Steve Russell in 1962, then Pong would never even have come about.
“The most important game I played was Spacewar! on a PDP-1 when I was in college,” he says, of the two-player space shooter that was popular among computer scientists and required a $120,000 machine to run. Although the visuals were nothing to write home about, the game was one of the first graphical video games ever made. It pitted two spaceships against each other and its popularity spread, in part, because the makers decided the code could be distributed freely to anyone who wanted it. “It was a great game, fun, challenging, but only playable on a very expensive computer late at night and the wee hours of the morning,” Nolan says. “In my opinion, it was a very important step.”
Nolan was so taken by Spacewar! that he made a version of the game with a colleague, Ted Dabney. Released in 1971, Computer Space allowed gamers to control a rocket in a battle against flying saucers, with the aim being to get more hits than the enemy in a set period of time. To make it attractive to players, it was placed in a series of colourful, space-age, moulded arcade cabinets. Nolan and Ted sold 1500 of them; even though they made just $500 from the venture, it was enough to spur them into continuing. They came up with the idea for Pong and created a company called Atari.
One of their best moves was employing engineer Al Alcorn, who had worked with Nolan at the American electronics company Ampex. Al was asked to create a table tennis game based on a similar title that had been released on the Magnavox Odyssey console, on the pretence that the game would be released by General Electric. In truth, Nolan simply wanted to work out Al’s potential, but he was blown away by what his employee came up with. Addictive and instantly recognisable, Atari realised Pong could be a major hit. The game’s familiarity with players meant it could be picked up and played by just about anyone.
Even so, Nolan had a hard time convincing others. Manufacturers turned the company down, so he visited the manager of a bar called Andy Capp’s in Sunnyvale, California and asked them to take Pong for a week. The manager soon had to call Nolan to tell him the machine had broken: it had become stuffed full of quarters from gamers who loved the game. By 1973, production of the cabinet was in overdrive and 8000 were sold. It led to the creation of a Pong home console which sold more than 150,000 machines. People queued to get their hands on one and Atari was on its way to become a legendary games company.
For Nolan, it was justification for his perseverance and belief. Suddenly, the man who had become interested in electronics at school, where he would spend time creating devices and connecting bulbs and batteries, was being talked of as a key player in the fledgling video game industry. But what did Nolan, Ted, Al, and the rest of the Atari team do to make the game so special? “We made it a good, solid, fun game to play,” says Nolan. “And we made it simple, easy, and quickly understood. Keeping things simple is more difficult to do than building something complex. You can’t dress up bad gameplay with good graphics.”
On the face of it, Pong didn’t look like much. Each side had a paddle that could be moved directly up and down using the controller, and the ball would be hit from one side to the other. The score was kept at the top of the screen and the idea was to force the opposing player to miss. It meant the game program needed to determine how the ball was hit and where the ball would go from that point. And that’s the crux of Pong’s success: the game encouraged people to keep playing and learning in the hope of attaining the skills to become a master.
When creating Pong, then, the designers had a few things in mind. One of the most important parts of the game was the movement of the paddles. This involved a simple, vertical rectangle that went up and down. One of the benefits Atari had when it created Pong was that it controlled not just the software but the hardware too. By building the cabinet, it was able to determine how those paddles should be moved. “The most important thing if you want to get the gameplay right is to use a knob to move the paddle,” advises Nolan. “No one has done a good Pong using touchscreens or a joystick.”
Look at a Pong cabinet close up – there are plenty of YouTube videos which show the game in action on the original machine – and you will see what Nolan means. You’ll notice that players turned a knob anticlockwise to move the paddle down, and clockwise to move it up. Far from being confusing, it felt intuitive.
With the paddles moving, Atari’s developers were able to look at the movement of the ball. At its most basic, if the ball continued to make contact with the paddles, it would constantly move back and forth. If it did not make contact, then it would continue moving in the direction it had embarked upon and leave the screen. At this stage, a new ball was introduced in the centre of the screen and the advantage was given to the player who had just chalked up a point. If you watch footage of the original Pong, you will see that the new ball was aimed at the player who had just let the ball go past. There was a chance he or she would miss again.
To avoid defeat, players had to be quite nifty on the controls and stay alert. Watching the ball go back and forth at great speed could be quite mesmerising as it left a blurred trail across the cathode ray tube display. There was no need to waste computing power by animating the ball because the main attention was focused on what would happen when it collided with the paddle. It had to behave as you’d expect. “The game did not exist without collisions of the ball to the paddle,” says Nolan.
Al realised that the ball needed to behave differently depending on where it hit the paddle. When playing a real game of tennis, if the ball hits the centre of the racket, it will behave differently from a ball that hits the edge. Certainly, the ball is not going to be travelling in a simple, straight path back and forth as you hit it; it is always likely to go off at an angle. This, though, is the trickiest part of making Pong “The ball should bounce up from an upper collision with more obtuse angles as the edge of the paddle is approached,” Nolan says. “This balances the risk of missing with the fact that an obtuse angle is harder to return.” This is what Pong is all about: making sure you hit the ball with the paddle, but in a manner that makes it difficult for the opposing player to return it. “A player wants the ball to be just out of reach for the opponent or be hard for him or her to predict.”
This post is part of a much longer deep dive into the history of Pong in Code the Classics, our 224-page hardback book that not only tells the stories of some of the seminal video games of the 1970s and 1980s, but also shows you how to use Python and Pygame Zero to create your own games inspired by them, following examples programmed by Raspberry Pi founder Eben Upton.
In conjunction with today’s blog post, we’re offering £1 off Code the Classics when you order your copy between now and midnight Wednesday 26 Feb 2020 from the Raspberry Pi Press online store. Simply follow this link or enter the discount code PONG at checkout to get your copy for only £11, with free shipping in the UK.
A Russian-speaking friend over at Farnell pointed us at this video. Apparently it’s been made by Amperkot.ru, a Russian Raspberry Pi Approved Reseller, who are running a t-shirt giveaway. We got our hands on a subtitled video, and…words fail me. Please turn the sound up before you start watching.
Следи за новостями 1) на сайте Amperkot.ru 2) в группе Вконтакте (vk.com/amperkot) 3) на канале в Телеграме (t.me/amperkot_ru)
We hope you enjoy this as much as we did. I have known Eben for more than twenty years now, and I’ve never seen him try to cram his whole fist into his mouth with mirth before.
Many thanks to Rapanui, who we wrote about here back in November. We suspect this will be as much of a surprise to them as it was to us. (The words coming out of Mart’s mouth are decidedly not his own.)
Update: as well as trying your luck in Amperkot’s giveaway, you can buy a Raspberry Pi t-shirt, as possibly modeled by Drake, from The Pi Hut!
If your amazing project is a little too quiet, add high-fidelity sound with Raspberry Pi and the help of this handy guide from HackSpace magazine, written by PJ Evans.
It’s no surprise that we love microcontrollers at HackSpace magazine. Their versatility and simplicity make them a must for electronics projects. Although a dab hand at reading sensors or illuminating LEDs, Arduinos and their friends do struggle when it comes to high-quality audio. If you need to add music or speech to your project, it may be worth getting a Raspberry Pi computer to do the heavy lifting. We’re going to look at the various audio output options available for our favourite small computer, from a simple buzz, through to audiophile bliss.
The simplest place to start is with the humble buzzer. A cheap active buzzer can be quickly added to Raspberry Pi’s GPIO. It’s surprisingly easy too. Try connecting a buzzer’s red wire (positive) to GPIO pin 22 (Broadcom numbering) and the black wire (ground) to any GND pin. Now, install the GPIO Zero Python library by typing this at the command line:
sudo apt install python3-gpiozero
Create a file called
buzz.py in your favourite editor and enter the following:
import time from gpiozero import Buzzer buzzer = Buzzer(22) buzzer.on() time.sleep(1) buzzer.off()
Run it at the command line:
You should hear a one-second buzz. See if you can make Morse code sounds by changing the duration of the
Raspberry Pi computers, with the exception of the Zero range, all have audio output on board. The original Raspberry Pi featured a stereo 3.5mm socket, and all A and B models since feature a four-pole socket that also includes composite video. This provides your cheapest route to getting audio from your Raspberry Pi computer.
A low-cost passive speaker can be directly plugged in to provide sound, albeit probably quieter than you’d like. Of course, add an amplifier or active speaker and you have sound as loud as you like. This is the most direct way of adding sound to your project, but how to get the sound out?
Normally, the Raspbian operating system will recognise that an audio device has been connected and route audio through it. Sometimes, especially if you’ve connected an HDMI monitor with sound capability (e.g. an HDMI TV), sound will not come out of the correct device.
To fix this, open up a terminal window and run
sudo raspi-config. When the menu appears, go to Advanced Options and select Audio, then select the option to force the output through the audio jack. You may need to reboot Raspbian for all changes to take effect.
A USB sound device is another simple choice for audio playback on Raspberry Pi. Literally hundreds are available, and a basic input/output device with better audio quality than the on-board system can be purchased for a few pounds online. Installation tends to be no more complicated than plugging the device into the USB port. You may need to select the new output, as the underlying audio system, ALSA (see the ALSA and PulseAudio section for more), may mute it by default. To fix this, run
alsamixer from the command line, press
F6 to select the new sound device, and if you see ‘MM’ at the bottom of the volume indicator, press
M to unmute and adjust the volume with the cursor keys.
Unsurprisingly, when choosing your USB sound device, you can start at a few pounds and go right up to professional equipment costing hundreds. As they are low-power, USB devices do not tend to feature amplification, unless they have a separate power source.
The simplest way to play audio on Raspbian is to use OMXPlayer. This is a dedicated hardware-accelerated command-line tool that takes full advantage of Raspberry Pi’s capabilities. It sends audio to the analogue audio jack by default, so playing back an MP3 file is as simple as running:
There are many command-line options that allow you to control how the audio is played. Want the audio to loop forever? Just add
--loop to the command. You’ll notice that when it’s running, OMXPlayer provides a user interface of sorts, allowing you to control playback from within the terminal. If you’d just like it to run in the background without user input, run the command like this:
omxplayer --no-keys example.wav &
—-no-keys removes the interface, and the ampersand (&) tells the operating system to run the job ‘in the background’ so that it won’t block anything else you want to do.
OMXPlayer is a great choice for Raspbian, but other players such as mpg321 are available, so find the tool that’s best for you.
Another useful utility is
speaker-test. This can produce white noise or vocal confirmation so you can check your speakers are working properly. It’s as simple as this:
speaker-test -t wav -c 2
The first parameter sets the sound to be a voice, and the
-c tests stereo channels only: front left and front right.
If space is an issue, a Raspberry Pi 4, amplifier, and speaker may not be what you have in mind. After all, your cool wearable project is going to be problematic if you’re trailing an amplifier on a cart with a 50-metre extension lead powering everything. Luckily, the clever people at Pimoroni have you covered. The Speaker pHAT is a Raspberry Pi Zero-sized HAT that not only adds audio capability to the smallest of the Raspberry Pi family, but also sports a 3 W speaker. Now you can play any audio with a tiny device and a USB battery pack.
The installation process is fully automated, so no messing around with drivers and config files. Once the script has completed, you can run any audio tool as before, and the sound will be routed through the speaker. No, the maximum volume won’t be troubling any heavy metal concerts, but you can’t knock the convenience and form factor.
An easy way to get superior audio quality using a Raspberry Pi computer is Bluetooth. Recent models such as the 3B, 4, and even the Zero W support Bluetooth devices, and can be paired with most Bluetooth speakers, even from the command line. Once connected, you have a range of options on size and output power, plus the advantage of wireless connectivity.
Setting up a Bluetooth connection, especially if you are using the command line, can be a little challenging (see the Bluetooth cheatsheet section). There is a succinct guide here: hsmag.cc/N6p2IB. If you are using Raspbian Desktop, it’s a lot easier. Simply click on the Bluetooth logo on the top-right, and follow the instructions to pair your device.
If you find OMXPlayer isn’t outputting any audio, try installing mpg321:
sudo apt install mpg321
And try again:
If your project needs good audio, and the standard 3.5 mm output just isn’t cutting it, then it’s time to look at the wide range of DACs (digital-to-analogue converters) available in HAT format. It’s a crowded market, and the prices vary significantly depending on what you want from your device. Let’s start at the lower end, with major player HiFiBerry’s DAC+ Zero. This tiny HAT adds 192kHz/24-bit playback via two RCA phono ports for £12.50. If you’re serious about your audio, then you can consider the firm’s full HAT format high-resolution DAC+ Pro for £36, or really go for it with the DSP (digital sound processing) version for £67. All of these will require amplification, but the sound quality will rival audio components of a much higher price.
Money no object? The Allo Katana is a monster DAC, and weighs in at £240, but outperforms £1000 equivalents
If money is no object and your project requires the best possible reproduction, then you can consider going full audiophile. There are some amazing high-end HATs out there, but one of the best-performing ones we’ve seen is the PecanPi DAC. Its creator Leonid Ayzenshtat sourced each individual component carefully, always choosing the best-in-class. He even used a separate DAC for each audio channel. The resulting board may make your wallet wince at around £200 for the bare board, but the resulting audio is good enough to be used in professional recording studios. If you’ve restored a gorgeous old radio back to showroom condition, you could do a lot worse than add the board in with a great amp and speaker.
There’s often confusion between these two systems. Raspbian comes pre-installed with ALSA (Advanced Linux Sound Architecture), which is the low-level software that makes sound work. It comes with a range of utilities to control output device, volume, and more. PulseAudio is a software layer that sits on top of ALSA to provide more features, including streaming capabilities. Chances are, if you need to do something a bit more clever than just play audio, you’ll need to install a PulseAudio server.
If you want to pair a Bluetooth audio device (A2DP) on the command line, it can be a little hairy. Here’s a quick guide:
sudo apt-get install pulseaudio pulseaudio-module-bluetooth sudo usermod -G bluetooth -a pi sudo reboot
Start the PulseAudio server:
Run the Bluetooth utility:
Put your speaker into pairing mode. Now, within the utility, run the following commands (pressing Enter after each one):
power on agent on scan on
Now wait for the list to populate. When you see your device…
<dev> is the displayed long identifier for your device. You can just type in the first few characters and press Tab to auto-complete. Do the same for the following steps.
trust <dev> connect <dev>
Wait for the confirmation, then enter:
Now try to play some audio using aplay (for WAV files) or mpg321 (for mp3). These instructions are adapted from the guide by Actuino at hsmag.cc/N6p2IB.
There are command-line players available for just about every audio format in common use. Generally, MP3 provides the best balance of quality and space, but lower bit-rates result in lower sound quality. WAV is completely uncompressed, but can eat up your SSD card. If you don’t want to compromise on audio quality, try FLAC, which is identical in quality to WAV, but much smaller. To convert between audio types, consider installing FFmpeg, a powerful audio and video processing tool.
If you love HackSpace magazine as much as we do, why not have a look at the subscription offers available, including the 12-month deal that comes with a free Adafruit Circuit Playground! Subscribers in the USA can now get a 12-month subscription for $60 when joining by the end of March!
And, as always, you can download the free PDF from the Raspberry Pi Press website.
The post How to play sound and make noise with your Raspberry Pi appeared first on Raspberry Pi.
Have you ever missed out on a great deal on Amazon because you were completely unaware it existed? Are you interested in a specific item but waiting for it to go on sale? Here’s help: Devscover’s latest video shows you how to create an Amazon price tracker using Raspberry Pi Zero W and Python.
Wayne from Devscover shows you how to code a Amazon Price Tracker with Python! Get started with your first Python project. Land a job at a big firm like Google, Facebook, Twitter or even the less well known but equally exciting big retail organisations or Government with Devscover tutorials and tips.
By following their video tutorial, you can set up a notification system on Raspberry Pi Zero W that emails you every time your chosen item’s price drops. Very nice.
Devscover’s tutorial is so detailed that it seems a waste to try and summarise it here. So instead, why not make yourself a cup of tea and sit down with the video? It’s worth the time investment: if you follow the instructions, you’ll end up with a great piece of tech that’ll save you money!
Remember, if you like what you see, subscribe to the Devscover YouTube channel and give them a thumbs-up for making wonderful Raspberry Pi content!
You really don’t need anything too fancy to build this Raspberry Pi laser scanner, and that’s why we think it’s pretty wonderful.
Cornell University: ECE 5725 Michael Xiao and Thomas Scavella
The ingredients you’ll need to build the laser scanner are:
To complete the build, access to a 3D printer and laser cutter would come in handy. If you don’t have access to such tools, we trust you to think of an alternative housing for the scanner. You’re a maker, you’re imaginative — it’s what you do.
The line laser projects a line an object, highlighting a slice of it. The Raspberry Pi Camera Module captures this slice, recording the shape of the laser line on the object’s surface. Then the stepper motor rotates the object. When the object has completed a full rotation and the camera has taken an image of every slice, the Raspberry Pi processes all the images to create one virtual 3D object.
Instructables user mfx2 has written a wonderful tutorial for the project, which also includes all files needed to build and program your own version.
Recently, we’ve seen an awful lot of new designs online for 3D-printable Raspberry Pi cases and add-ons. Here are a few that definitely need your attention.
Described as “a Turbine-fin Lamp with some RGB Neopixels in the middle,” this print from Thingiverse user kryptn would be a rather lovely addition to any desk or bedside table.
These two lovely network-attached storage (NAS) prints will allow you to store your files via your network…it’s all in the name.
The internet is crowded with Raspberry Pi cases you can print, but few are as eye-catching at this Raspberry Pi Zero case by jwillmer.
The IKEA Skadis system is becoming more and more popular in workshops, studies, and craft rooms. So why not print this perfectly-sized shelf to fit your Raspberry Pi and official Raspberry Pi case into the system as well?
Is this cheating? You can use this file to 3D-print your own version of the Raspberry Pi 4 cooling stand that we’re currently giving away for free on the front of The MagPi magazine.
If you’ve designed any 3D-printable Raspberry Pi accessories, share them with us in the comments below!
There’s more than one option when it comes to selecting infill patters for your 3D prints. But what are the differences, and why should you use one over the …
The post 3D-printable Raspberry Pi bits and pieces you should totally make appeared first on Raspberry Pi.
Learn how to use an LED with Raspberry Pi in our latest How to use video on YouTube.
Subscribe to our YouTube channel: http://rpf.io/ytsub Help us reach a wider audience by translating our video content: http://rpf.io/yttranslate Buy a Raspberry Pi from one of our Approved Resellers: http://rpf.io/ytproducts Find out more about the #RaspberryPi Foundation: Raspberry Pi http://rpf.io/ytrpi Code Club UK http://rpf.io/ytccuk Code Club International http://rpf.io/ytcci CoderDojo http://rpf.io/ytcd Check out our free online training courses: http://rpf.io/ytfl Find your local Raspberry Jam event: http://rpf.io/ytjam Work through our free online projects: http://rpf.io/ytprojects Do you have a question about your Raspberry Pi?
LEDs (light-emitting diodes) are incredibly useful in digital making projects. You can use one to indicate whether a script is running or when an action can take place, or as decoration, and for so much more besides.
Blinking an LED with the help of Raspberry Pi has become a rite of passage for new digital makers: it’s the physical equivalent of the ‘hello world’ program! Therefore, it’s the first thing that the participants in our Picademy training, and many young people in physical computing sessions at coding clubs in our networks, learn how to do.
Follow the steps in our latest How to use video to learn how to control an LED with your Raspberry Pi, and go get making.
And, while you’re in a subscribe-y mood, also subscribe to the Raspberry Pi Press YouTube channel, the home of all content from The MagPi, HackSpace magazine, WireFrame, Custom PC, and more.
Punch and kick your way through a rabble of bad dudes in a simple scrolling beat-’em-up. Mark Vanstone shows you how
Although released to tie in with Jackie Chan’s Spartan X, Kung-Fu Master was originally inspired by the Bruce Lee film, Game of Death.
Kung-Fu Master hit arcades in 1984. Its side-scrolling action, punching and kicking through an army of knife-throwing goons, helped create the beat-’em-up genre. In fact, its designer, Takashi Nishiyama, would go on to kickstart the Street Fighter series at Capcom, and later start up the Fatal Fury franchise at SNK.
In true eighties arcade style, Kung-Fu Master distils the elements of a chop-socky action film to its essentials. Hero Thomas and his girlfriend are attacked, she’s kidnapped, and Thomas fights his way through successive levels of bad guys to rescue her. The screen scrolls from side to side, and Thomas must use his kicks and punches to get from one side of the level to the other and climb the stairs to the next floor of the building.
Our Kung-Fu Master homage features punches, kicks, and a host of goons to use them on.
To recreate this classic with Pygame Zero, we’ll need quite a few frames of animation, both for the hero character and the enemies he’ll battle. For a reasonable walk cycle, we’ll need at least six frames in each direction. Any fewer than six won’t look convincing, but more frames can achieve a smoother effect. For this example, I’ve used the 3D package Poser, since it has a handy walk designer which makes generating sequences of animation much easier.
Once we have the animation frames for our characters, including a punch, kick, and any others you want to add, we need a background for the characters to walk along. The image we’re using is 2000×400 pixels, and we start the game by displaying the central part so our hero can walk either way. By detecting arrow key presses, the hero can ‘walk’ one way or the other by moving the background left and right, while cycling through the walk animation frames. Then if we detect a
Q key press, we change the action string to kick; if it’s
A, it’s punch. Then in our
update() function, we use that action to set the Actor’s image to the indicated action frame.
Our enemy Actors will constantly walk towards the centre of the screen, and we can cycle through their walking frames the same way we do with the main hero. To give kicks and punches an effect, we put in collision checks. If the hero strikes while an enemy collides with him, we register a hit. This could be made more precise to require more skill, but once a strike’s registered, we can switch the enemy to a different status that will cause them to fall downwards and off the screen.
This sample is a starting point to demonstrate the basics of the beat-’em-up genre. With the addition of flying daggers, several levels, and a variety of bad guys, you’ll be on your way to creating a Pygame Zero version of this classic game.
Because we’re moving the background when our hero walks left and right, we need to make sure we move our enemies with the background, otherwise they’ll look as though they’re sliding in mid-air – this also applies to any other objects that aren’t part of the background. The number of enemies can be governed in several ways: in our code, we just have a random number deciding if a new enemy will appear during each update, but we could use a predefined pattern for the enemy generation to make it a bit less random, or we use a combination of patterns and random numbers.
You can read more features like this one in Wireframe issue 32, available now at Tesco, WHSmith, all good independent UK newsagents, and the Raspberry Pi Store, Cambridge.
Or you can buy Wireframe directly from Raspberry Pi Press — delivery is available worldwide. And if you’d like a handy digital version of the magazine, you can also download issue 32 for free in PDF format.
Look how lovely and glowy it is.
The post Code a Kung-Fu Master style beat-’em-up | Wireframe #32 appeared first on Raspberry Pi.
Are you an academic, researcher, student, or educator who is interested in computing education research? Then come and join us in Cambridge, UK on 1 April 2020 for discussion and networking at our first-ever research symposium.
Dr Natalie Rusk from the MIT Media Lab is our keynote speaker
At the Raspberry Pi Foundation, we carry out research that deepens our understanding of how young people learn about computing and digital making and helps to increase the impact of our work and advance the field of computing education.
As part of our research work, we are launching the Cambridge Computing Education Research Symposium, a new one-day symposium hosted jointly by us and the University of Cambridge.
The theme of the symposium is school-level computing education, both formal and non-formal. The symposium will offer an opportunity for researchers and educators to share their work, meet others with similar interests, and build collaborative projects and networks.
The William Gates Building in Cambridge houses the Department of Computer Science and Technology (Computer Laboratory) and will be the symposium venue
The symposium will take place on 1 April 2020 at the Department of Computer Science and Technology. The day will include a range of talks and a poster session, as well as a keynote speech from Dr Natalie Rusk, Research Scientist at the MIT Media Laboratory and one of the creators of the Scratch programming language.
Registration for the symposium is now open: book your place today!
When you register to attend, you’ll also have the chance to sign up for one of two parallel workshops taking place on 31 March 2020 at the Raspberry Pi Foundation office in Cambridge.
Workshop 1 concerns the topic of gender balance in computing, while in workshop 2, we’ll consider what research-in-practice looks like in the computing classroom.
The workshops will draw on the experiences of everyone who is participating, and they’ll provide a forum for innovative ideas and new opportunities for collaboration to emerge.
You’re also invited to join us on the evening of 31 March for an informal networking event over food and drink at the Raspberry Pi Foundation office — a great chance to meet, mingle, and make connections ahead of the symposium day.
Register for the symposium to secure your place at these events! We look forward to meeting you there.
The post Attend our Cambridge Computing Education Research Symposium appeared first on Raspberry Pi.
Today we’re launching a time-limited special offer on subscriptions to HackSpace magazine and The MagPi magazine for readers in the USA, saving you a whopping 48% compared to standard overseas subscriptions. We want to help as many people as possible get their hands on our fantastic publications.
Starting today, you can subscribe to these magazines for the discounted price of $60 a year – just $5 per issue. Not only will you receive twelve issues direct to your door, but you’ll also receive a free gift and save up to 35% compared with newsstand prices!
You’ll need to be quick – this discounted offer is only running until 31 March 2020.
HackSpace magazine is packed with projects for fixers and tinkerers of all abilities. We’ll teach you new techniques and give you refreshers on familiar ones, from 3D printing, laser cutting, and woodworking to electronics and the Internet of Things. HackSpace magazine will inspire you to dream bigger and build better.
The MagPi is the official Raspberry Pi magazine. Written by and for the community, it’s packed with Raspberry Pi-themed projects, computing and electronics tutorials, how-to guides, and the latest news and reviews.
To help spread the word about this special offer, we’re running a little no-purchase-required giveaway.
Just retweet this tweet with the hashtag #WinARaspberryPiThing, and we’ll pick five of you to win a Raspberry Pi bookazine of your choice, signed by whichever members of the Raspberry Pi team Alex can pull away from the scrum around the coffee machine.
If you don’t have Twitter, you can leave your favourite (family-friendly) knock-knock joke in the blog comments below and we’ll pick two more winners from there too!
The winners can choose any of the following:
We’ll pick winners on 1 April 2020, so you have a month and a bit to share the love!
The post USA magazine subscriptions offer: 48% off standard prices appeared first on Raspberry Pi.
How many types of infill pattern have you tried? The latest video from Raspberry Pi Press takes a closer look at 3D printing infill patterns, and why you may want to use a certain pattern over another.
There’s more than one option when it comes to selecting infill patters for your 3D prints. But what are the differences, and why should you use one over the other? #HackSpacemagazine is the monthly magazine for people who love to make things and those who want to learn.
Raspberry Pi Press publishes a variety of magazines and books, and the Raspberry Pi Press YouTube channel covers them all. Subscribe today to keep up to date with all new video releases, and let us know in the video comments what other content you’d like to see.
The post 3D printing infill patterns — what, why, and why not! appeared first on Raspberry Pi.
The last major release of Raspbian was the Buster version we launched alongside Raspberry Pi 4 last year. There was a minor release a couple of months later, which was mostly just bug-fixes for the first release (hence no blog post), but today’s release has a few changes that we thought it was worth bringing to your attention.
We previously made some significant changes to the PCmanFM file manager included as part of the Raspberry Pi Desktop; we added a cutdown mode which removes a lot of the less commonly used functions, and we set this as the default mode.
One of the things we removed for this mode is the Places view, an optional view for the left-hand pane of the window which provides direct access to a few specific locations in the file system. We felt that the directory browser was more useful, so we chose to show that instead. But one useful feature of Places is that it displays external devices, such as USB drives, and these are somewhat awkward to find in the file manager otherwise.
So for this release, the Places view has been reinstated, but rather than being a separate switchable view, it is a small panel at the top of the directory browser. This hopefully gives the best of both worlds: easy access to USB drives, and a directory view. You can customise what is shown in the Places view on the Layout page of the file manager Preferences dialogue, or you can turn it off completely if you’d rather just have the directory browser.
There are a few other small changes to the file manager: there is now a new folder icon on the taskbar, and the expanders in the directory browser (the little triangles next to directory names) are now only shown when a directory has subdirectories.
Finally, the folder and file icons used in the file manager have been replaced with some new, cleaner designs. These are designed to make it more obvious at a glance what sort of file an icon represents, and also to fit better with the slightly flatter GUI appearance we moved to for Buster.
One area of the desktop which we have been wanting to improve for some time is accessibility, particularly for those with visual impairments. To this end, we asked the accessibility charity AbilityNet to assess the Raspberry Pi Desktop to see how usable it was for those with disabilities, and where we could make improvements.
They gave us a lot of very helpful feedback, and their number one suggestion was that we needed to make the Orca screen reader work with the desktop.
Orca is an application which uses synthesised speech to read out menus, window titles, button labels, and the like. It’s a standard Linux application, but people who have tried it on Raspberry Pi found that it didn’t actually work with Raspbian. (When I first installed it, all it did was to make slightly alarming growling noises instead of speaking!)
After quite a bit of fiddling and head-scratching, Orca now works as intended. It will read out many of the pre-installed applications, and should work with a lot of other Linux software packages as well.
Unfortunately, there are a few areas where it won’t work. Orca hooks into various user interface toolkits — the software which is used to draw buttons, menus, etc. on the screen. It is fully compatible with the GTK toolkit (which is used for most of the desktop) and Qt (which is used for the VLC media player and the qpdfview PDF viewer). But many applications (such as Thonny, Sonic Pi, and Scratch) are built on toolkits which are not compatible with the screen reader. Also, the current release of Chromium is not compatible with Orca, but the forthcoming version 80 release, which should be available in a few months, will be Orca-compatible. In the meantime, if you want an Orca-compatible browser, you can install Firefox by entering the following into a terminal window:
sudo apt install firefox-esr
(Please note that we do not recommend using Firefox on Raspbian unless you need Orca compatibility, as it is not optimised for video playback on the Pi in the same way as Chromium.)
Orca doesn’t have a menu entry — the settings dialog shown above can be opened by holding down the Insert key and then pressing the space bar, or by typing orca -s into a terminal window.
Please note that Orca currently doesn’t work with Bluetooth audio devices, so we recommend using it with either the Pi’s own HDMI output or headphone socket, or with a USB or HAT external audio device.
Orca can either be installed from Recommended Software, in the Universal Access category, or by entering the following into a terminal window:
sudo apt install orca
This is hopefully just the start of making the Raspberry Pi Desktop more accessible for those with disabilities, as we are planning to do more work in this area in the future.
Scratch 3 has added the ability to load a project from the command line at launch (scratch3 filename.sb3).
There are also two new blocks in the Sense HAT extension, ‘display stage’ and ‘display sprite’. The first of these shows the current stage on the SenseHAT LED array; the second shows the current sprite on the LEDs.
A lot of work has been done on Thonny to improve performance, particularly when debugging. In previous releases, setting breakpoints caused performance to slow down significantly — this was particularly obvious when running PyGame Zero games, where the frame rate was very slow. The new version is substantially faster, as you can see if you set breakpoints in any of…
…the Python games from Eben’s book Code the Classics – Volume 1, which are now installable from Recommended Software, and can be found in the Games menu.
If you want to look at the code for the games, this can be found in
In previous releases, there was an Audio Device Preferences application in the main menu to enable device-specific settings to be made for external audio devices. This has now been removed; all these settings are now available directly from the volume plugin on the taskbar. With an external device selected as the output or input device, right-click the volume icon and choose the Output Device Settings… or Input Device Settings… option to open the configuration dialog.
The option to disable the timeout which blanks the screen after a few minutes has been added to Raspberry Pi Configuration. To try and reduce clutter in this application, the options from the System tab are now split across two tabs; all display-related options, including screen blanking, are now on the new Display tab.
We’ve also been able to reinstate the pixel doubling option for Raspberry Pi 4; this was originally implemented in a manner incompatible with the KMS video driver used on Raspberry Pi 4, but we’ve now found a way to make it work with KMS. (The pixel doubling option is designed to make the Raspberry Pi’s screen easier to use for people with visual disabilities — it doubles the size of every pixel, scaling the entire screen by a factor of two.)
We’ve made one minor change to key shortcuts: in previous versions of Raspbian, the combination Ctrl-Alt-Delete launched the task manager. We felt it might be better to be consistent with the behaviour of Windows PCs since the dawn of time, so now Ctrl-Alt-Delete launches the shutdown options dialog. If you want to access the task manager with a key shortcut, you can now do so using Ctrl-Shift-Escape — also consistent with the behaviour of Windows.
There are also numerous other small bug fixes and robustness improvements across the board.
The new image is available for download from the usual place: our Downloads page.
To update an existing image, use the usual terminal command:
sudo apt update sudo apt full-upgrade
We hope you like the changes — as ever, all feedback is welcome, so please leave a comment below!
Keeping a modern cat entertained requires something more high-tech than a ball of yarn. The MagPi’s Phil King wonders if this is a purr-fect project…
WARNING! LASER EYE! Don’t look into a laser beam, and don’t point a laser beam at a somebody’s head. For more on things you SHOULDN’T do with a laser, visit magpi.cc/lasersafety.
Xander the cat is a much-loved family pet, but as his owners live in a flat, he can get a little bored staying indoors when they’re out at work. Seeking a way to keep his cat entertained, Enzo Calogero came up with an ingenious Raspberry Pi–powered project. “We noticed that he loves to chase a laser light, so we decided to create a device to make laser games for him,” explains Enzo.
The result is the Tri-Lasers for Felines device which, when the cat’s presence is detected by a PIR motion sensor, beams a laser dot around the room for Xander to chase between randomly generated points. Judging by the video on the project’s Hackster tutorial page, he seems to love it.
This video is about trilaser
The laser’s main movement trajectory is handled by mounting it on a Pan-Tilt HAT, which has vertical and horizontal servo motors. “A pair of coordinates (x, y) is generated randomly,” explains Enzo. “The laser point moves from the current point to a new coordinate, following the segment that connects the two points, at a speed defined by a status variable. Once the new coordinates are reached, we loop back to point one.”
To add extra interest for Xander, its movement is randomised further by switching between three laser diodes to perform micro random movements very quickly. “Switching the active laser among the three allows extremely rapid movements of the laser dot, to create an extra variability of the light trajectories which seems more enjoyable for the cat,” says Enzo.
While the laser point is visible in daylight, it shows up better when there’s less light: “Xander prefers it when the room is completely dark.”
The device’s three laser diodes are set into a 3D-printed triangular holder that sits atop the Pan-Tilt HAT’s acrylic mount — which would normally be used to hold a Camera Module. Enzo also designed and 3D-printed a case for the PIR sensor.
In addition to handling laser movement, the Python script saves a log of Xander’s activity: “We check it now and then out for curiosity,” says Enzo. “When Xander was a kitten, he was playing with it very often. Now he is a bit older and much more prone to sleep rather than play, we switch it on when we are out in the evening to keep him busy during our prolonged absence.”
One issue that came up is that, being naturally curious animals, cats are prone to investigate any new objects. “We try to put it as high and unreachable as possible, but cats are extremely skilled,” says Enzo. “So, he was able to reach the device few times. And the best way to save the device from cat attacks is to make it as still as possible, so the cat loses interest.”
Therefore a tilt sensor was added to the device, to cause it to shut down if triggered by an inquisitive Xander, thus reducing the risk of damage.
This isn’t the only feline-focused project from Enzo, who has also built an IoT food scale to monitor when and how much Xander eats, sending the data to a Google Cloud online dashboard. He’s now working on a wheeled robot to track the cat with a camera and perform a few interactions — we wonder what Xander will make of that.
The MagPi magazine is available from newsagents in the UK, Barnes & Noble in the US, the Raspberry Pi Store here in Cambridge, and online in the Raspberry Pi Press store.
This month’s issue comes with a free stand for your Raspberry Pi 4. Yay!
Some cats don’t like lasers. They find it far too upsetting when they can’t catch what it is they’re chasing. If your cat starts to pant while chasing lasers, don’t assume it’s just exhausted. Panting can be a sign of stress in cats, and stressed is something your cat shouldn’t be. Exercise caution when playing with your cat and laser toys, and consult a vet if you’re unsure whether their behaviour is normal.
The owner of a cat who doesn’t like laser toys
Learn how to use a servo motor with Raspberry Pi in our latest How to use video on YouTube.
Subscribe to our YouTube channel: http://rpf.io/ytsub Help us reach a wider audience by translating our video content: http://rpf.io/yttranslate Buy a Raspberry Pi from one of our Approved Resellers: http://rpf.io/ytproducts Find out more about the #RaspberryPi Foundation: Raspberry Pi http://rpf.io/ytrpi Code Club UK http://rpf.io/ytccuk Code Club International http://rpf.io/ytcci CoderDojo http://rpf.io/ytcd Check out our free online training courses: http://rpf.io/ytfl Find your local Raspberry Jam event: http://rpf.io/ytjam Work through our free online projects: http://rpf.io/ytprojects Do you have a question about your Raspberry Pi?
Over the next few months, we’ll be releasing more videos in our How to use series, including guides on the use of LEDs, buzzers, and sensors with your Raspberry Pi.
What other components do you think we should cover? While we can’t make videos for every available component on the market, we’d love to hear what you, our community, believe to be integral to the maker toolkit.
And, while you’re in a subscribe-y mood, also subscribe to the Raspberry Pi Press YouTube channel, the home of all content from The MagPi, HackSpace magazine, WireFrame, Custom PC, and more.
At Raspberry Pi, we’re interested in all things to do with technology, from building new tools and helping people teach computing, to researching how young people learn to create with technology and thinking about the role tech plays in our lives and society. Today, I’m writing about our habit of replacing devices with newer versions just for the sake of it.
Technology is involved in more of our lives than ever before: most of us carry a computer in our pocket everywhere we go. On the other hand, the length of time for which we use each individual piece of technology has grown very short. This is what’s referred to as upgrade culture, a cycle which sees most of us replacing our most trusted devices every two years with the latest products offered by tech giants like Apple and Samsung.
How we got to this point is hard to determine, and there does not seem to be a single root cause for upgrade culture. This is why I want to start a conversation about it, so we can challenge our current perspectives and establish fact-based attitudes. I think it’s time that we, as individuals and as a collective, examine our relationship with new technology.
Digital technology is still so new that there is really no benchmark for how long digital devices should last. This means that the decision power has by default landed in the hands of device manufacturers and mobile network carriers, and for their profit margins, a two-year lifecycle of devices is beneficial.
Where do you see your role in this process as a consumer? Is it wrong to want to upgrade your phone after two years of constant use? Should phone companies slow their development, and would this hinder innovation? And, if you really need to upgrade, is there a better use for your old device than living in a drawer? These questions defy simple answers, and I want to hear what you think.
As with all our behaviours as consumers, the impact that upgrade culture has on the environment is an important concern. Environmental issues and climate change aren’t anything new, but they’re currently at the forefront of the global conversation, and for good reason.
Mobile devices are of course made in factories, and the concerns this raises have been covered well in many other places. The same goes for the energy needed to build technology. This energy could, at least in theory, be produced from renewable sources. Here I would like to focus on another aspect of the environmental impact device production has, which relates to the materials necessary to create the tiny components that form our technological best friends.
Some components of your phone cannot be created without rare chemical elements, such as europium and dysprosium. (In fact, there are 83 stable non-radioactive elements in the periodic table, and 70 of them are used in some capacity in your phone.) Upgrade culture means there is high demand for these materials, and deposits are becoming more and more depleted. If you’re hoping there are renewable alternatives, you’ll be disappointed: a study by researchers working at Yale University found that there are currently no alternative materials that are as effective.
Then there’s the issue of how the materials are mined. The market trading these materials is highly competitive, and more often than not manufacturers buy from the companies offer the lowest prices. To maintain their profit margin, these companies have to extract as much material as possible as cheaply as they can. As you can imagine, this leads to mining practices that are less than ethical or environmentally friendly. As many of the mines are located in distant areas of developing countries, these problems may feel remote to you, but they affect a lot of people and are a direct result of the market we are creating by upgrading our devices every two years.
Many of us agree that we need to do what we can to counteract climate change, and that, to achieve anything meaningful, we have to start looking at the way we live our lives. This includes questioning how we use technology. It will be through discussion and opinion gathering that we can start to make more informed decisions — as individuals and as a society.
You probably also have that one friend/colleague/family member who swears by their five year old mobile phone and scoffs at the prices of the newest models. These people are often labeled as sticklers who are afraid to join the modern age, but is there another way to see them? The truth is, if you’ve bought a phone in the last five years, then — barring major accidents — it will most likely still function and be just as effective as it was when it came out of the box. So why are so many consumers upgrading to new devices every two years?
Again there isn’t a single reason, but I think marketing departments should shoulder much of the responsibility. Using marketing strategies, device manufacturers and mobile network carriers purposefully make us see the phones we currently own in a negative light. A common trope of mobile phone adverts is the overwrought comparison of your current device with a newly launched version. Thus, each passing day after a new model is released, our opinion of our current device worsens, even if it’s just on a subconscious level.
This marketing strategy is related to a business practice called planned obsolescence, which sees manufacturers purposefully limit the durability of their products in order to sell more units. An early example of planned obsolescence is the lightbulb, invented at the Edison company: it was relatively simple for the company to create a lightbulb that lasted 2500 hours, but it took years and a coalition of manufacturers to make a version that reliably broke after 1000 hours. We’re all aware that the lightbulb revolutionised many aspects of life, but it turns out it also had a big influence on consumer habits and what we see as acceptable practices of technology companies.
The final aspect of the impact of upgrade culture that I want to examine relates to the digital divide. This term describes the societal gap between the people with access to, and competence with, the latest technology, and the people without these privileges. To be able to upgrade, say, your mobile phone to the latest model every two years, you either need a great degree of financial freedom, or you need to tie yourself to a 24-month contract that may not be easily within your means. As a society, we revere the latest technology and hold people with access to it in high regard. What does this say to people who do not have this access?
Inadvertently, we are widening the digital divide by placing more value on new technology than is warranted. Innovation is exciting, and commercial success is celebrated — but do you ever stop and ask who really benefits from this? Is your new phone really that much better than the old one, or could it be that you’re mostly just basking in feeling the social rewards of having the newest bit of kit?
Obviously, this blog post wouldn’t be complete if we didn’t share our perspective as a technology company as well. So here’s Raspberry Pi Trading CEO Eben Upton:
“Raspberry Pi tries very hard to avoid obsoleting older products. Obviously the latest Raspberry Pi 4 runs much faster than a Raspberry Pi 1 (something like forty times faster), but a Raspbian image we release today will run on the very earliest Raspberry Pi prototypes from the summer of 2011. Cutting customers off from software support after a couple of years is unethical, and bad for business in the long term: fool me once, shame on you; fool me twice, shame on me. The best companies respect their customers’ investment in their platforms, even if that investment happened far in the past.”
“What’s even more unusual about Raspberry Pi is that we aim to keep our products available for a long period of time. So you can’t just run a 2020 software build on a 2014 Raspberry Pi 1B+: you can actually buy a brand-new 1B+ to run it on.”
“We’re constantly working to reduce the environmental footprint of Raspberry Pi. If you look next to the USB connectors on Raspberry Pi 4, you’ll see a chunky black component. This is the reservoir capacitor, which prevents the 5V rail from dropping too far when a new USB device is plugged in. By using a polymer electrolytic capacitor, from our friends at Panasonic, we’ve been able to avoid the use of tantalum.”
“When we launched the official USB-C power supply for Raspberry Pi 4, one or two people on Twitter asked if we could eliminate the single-use plastic bag which surrounded the cable and plug assembly inside the box. Working with our partners at Kuantech, we found that we could easily do this for the white supplies, but not for the black ones. Why? Because when the box vibrates in transit, the plug scuffs against the case; this is visible on the black plastic, but not on the white.”
Raspberry Pi power supply with scuff mark
“So for now, if you want to eliminate single-use plastic, buy a white supply. In the meantime, we’ll be working to find a way (probably involving cunning origami) to eliminate plastic from the black supply.”
Time for you to discuss! I want to hear from you about upgrade culture.
Share your thoughts in the comments!
Upgrade culture is one of the topics for which we offer you a discussion forum on our free online course Impact of Technology. For educators, the course also covers how to facilitate classroom discussions about these topics, and a new course run has just begun — sign up today to take part for free!
The Impact of Technology online course is one of many courses developed by us with support from Google.
Raspberry Pi’s own Mac Bowley shows you how to make the beginnings of a top-down driving game inspired by 1983’s Spy Hunter.
Spy Hunter was one of the very first games with both driving and shooting.
The 1983 arcade classic Spy Hunter put players at the wheel of a fictitious Interceptor vehicle and challenged them to navigate a vertically scrolling road, destroying enemy vehicles.
Here, I’ll show you how you can recreate the game’s scrolling road to use in your own driving games. The road will be created using the Rect class from Pygame, with the road built from stacked rectangles that are each two pixels high.
First, I create two lists; one to hold the pieces of road currently being drawn on screen, and another to hold a queue of pieces that will be added as the road scrolls. To create the scrolling road effect, each of the current pieces of road will need to move down the screen, while a new piece is added to the end of the list at position y = 0.
Pygame can schedule functions, which can then be called at set intervals – meaning I can scroll my road at a set frame rate. The
scroll_road function will achieve this. First, I loop over each road piece, and move it down by two pixels. I then remove the first item in the queue list and append it to the end of the road. The Pygame clock is then set to call the function at intervals set by a
frame_rate variable: mine is set to 1/60, meaning 60 frames per second.
Our code snippet provides a solid basis for your own top-down driving game. All you need now are weapons. And a few other cars.
My road can either turn left or right, a random choice made whenever the queue is populated. Whichever way the road turns, it has to start from the same spot as the last piece in my queue. I can grab the last item in a list using -1 as an index and then store the x position; building from here will make sure my road is continuous. I use a buffer of 50 pixels to keep the road from moving off the edge of my screen – each time a turn is made, I check that the road doesn’t go beyond this point.
I want the turn amount to be random, so I’m also setting a minimum turn of 200 pixels. If this amount takes my car closer than the buffer, I’ll instead set the turn amount so that it takes it up to the buffer but no further. I do this for both directions, as well as setting a modifier to apply to my turn amount (-1 to turn left and 1 to turn right), which will save me duplicating my code. I also want to randomly choose how many pieces will be involved in my turn. Each piece is a step in the scroll, so the more pieces, the longer my turn will take. This will make sure I have a good mix of sharp and elongated turns in my road, keeping the player engaged.
To make things more exciting, the game can also be speeded up by decreasing the
frame_rate variable. You could even gradually increase this over time, making the game feel more frantic the further you get.
Another improvement would be to make the turns more curvy, but make sure you’re comfortable with algebra before you do this!
You can read more features like this one in Wireframe issue 31, available now at Tesco, WHSmith, all good independent UK newsagents, and the Raspberry Pi Store, Cambridge.
Or you can buy Wireframe directly from Raspberry Pi Press — delivery is available worldwide. And if you’d like a handy digital version of the magazine, you can also download issue 31 for free in PDF format.
The post Make a Spy Hunter-style scrolling road | Wireframe #31 appeared first on Raspberry Pi.
Following on from our recent announcement that Raspberry Pi 4 is OpenGL ES 3.1 conformant, we have some more news to share on the graphics front. We have started work on a much requested feature: an open-source Vulkan driver!
Standards body Khronos describes Vulkan as “a new generation graphics and compute API that provides high-efficiency, cross-platform access to modern GPUs”. The Vulkan API has been designed to better accommodate modern GPUs and address common performance bottlenecks in OpenGL, providing graphics developers with new means to squeeze the best performance out of the hardware.
The “first triangle” image is something of a VideoCore graphics tradition: while I arrived at Broadcom too late to witness the VideoCore III version, I still remember the first time James and Gary were able to get a flawless, single-tile, RGB triangle out of VideoCore IV in simulation. So, without further ado, here’s the VideoCore VI Vulkan version.
Before you get too excited, remember that this is just the start of the development process for Vulkan on Raspberry Pi. While there have been community efforts in the direction of Vulkan support (originally on VideoCore IV) as far back as 2018, Igalia has only been working on this new driver for a few weeks, and we still have a very long development roadmap ahead of us before we can put an actual driver in the hands of our users. So don’t hold your breath, and instead look forward to more news from us and Igalia as they make further development progress.
In issue 88 of The MagPi, we discovered that Raspberry Pi 4 can be kept cooler than usual if placed on its side. This gave us an idea, and thanks to many Top People, it resulted in the small, simple, and very practical Raspberry Pi 4 stand that you will find on the cover of all physical copies of The MagPi 90.
To complement this gift, we also got heat tester extraordinaire Gareth Halfacree to put the stand and several cooling cases through their paces to see just how well they can keep Raspberry Pi 4 nice and cool.
The stand also has an extra benefit: you can place three Raspberry Pis in it at once! A good idea if you plan to do a little cluster computing with a few Raspberry Pi 4s.
While the Raspberry Pi 4 stand is a pretty big deal all by itself, issue 90 of The MagPi also includes a guide to building the ultimate smart mirror — including a bit of voice control!
While a magic mirror may not show you who the fairest of them all is (I can answer that question for you: it’s me), our guide will definitely show you the easiest way to set up your own magic mirror. It’ll be straightforward, thanks to the complete step-by-step tutorial we’ve put together for you.
Feeling the urge to make something new with Raspberry Pi? Then take a look at our amazing selection of project showcases, and at a feature of some easy starter projects to help you get inspired. All this, along with our usual selection of reviews, tutorials, and community news, in The MagPi 90!
You can get The MagPi issue 90 online in our store with international delivery available, or from the Raspberry Pi Store in Cambridge and all good newsagents and supermarkets. You can also access The MagPi magazine via our Android and iOS apps.
The stand is available with print copies of the magazine
And, as with all our Raspberry Pi publications, you can download this issue as a free PDF from our website.
The post Free Raspberry Pi 4 cooling stand with The MagPi 90! appeared first on Raspberry Pi.
Raspberry Pi Press is back with a new publication: this time, it’s Wireframe’s time to shine, with Build Your Own First-Person Shooter in Unity.
Ever fancied creating your own first-person shooter game? Now you can with Wireframe’s brand new, 140-page bookazine, which positively heaves with tutorials and advice from expert video game developers!
We’ve all had that moment of asking ourselves, “I wonder if I could do this?” when playing a video game. Whether as a child racing friends in Mario Kart, or in more recent years with vast open-world masterpieces, if you like games, you’ve probably thought about designing and building your own.
So, why don’t you?
With the latest publication from Wireframe and Raspberry Pi Press, you can learn how to use Unity, free software available to download online, to create your very own first-person shooter. You could build something reminiscent of DOOM, Wolfenstein, and all the other games you tried to convince your parents you were old enough to play when you really weren’t (who knew blurry, pixelated blood could be so terrifying?).
Build Your Own First-Person Shooter in Unity leads you step-by-step through the process of making the game Zombie Panic – a frenetic battle for survival inside a castle heaving with the undead.
You’ll learn how to set up and use all the free software you’ll need, make enemies that follow and attack the player, create and texture 3D character models, and design levels with locked doors and keys.
You’ll also get tips and advice from experts, allowing you to progress your game making beyond the tutorials in the book.
Build Your Own First-Person Shooter in Unity is available now from the Raspberry Pi Press online store with free worldwide shipping, from the Raspberry Pi Store in Cambridge, and as a free download from the Wireframe website.
Yup, you read correctly. Build Your Own First-Person Shooter in Unity can be downloaded for free as a PDF from the Wireframe website. We release free PDF versions of our books and magazines on the day they’re published; it means as many people as possible can get their hands on high-quality, up-to-date information about computing, programming and making.
However, when you buy our publications, you help us produce more great content, and you support the work of the Raspberry Pi Foundation to bring computing and digital making to people all over the world. We offer a variety of subscription options, including some terrific free gifts. And we make sure our publications are printed to feel good in your hands and look good on your bookshelf.
So, buy Build Your Own First-Person Shooter in Unity if you can – thank you, you’re amazing! And if not, grab the free PDF. Whichever you choose, we hope you make an awesome game. Don’t forget to share it with us on our social media channels.
Our brand-new trailer for HackSpace magazine is very pretty. Here, have a look for yourself.
HackSpace magazine is the new monthly magazine for people who love to make things and those who want to learn. Grab some duct tape, fire up a microcontroller, ready a 3D printer and hack the world around you!
As we mentioned last week, this month’s HackSpace magazine contains a very cool Raspberry Pi special feature that we know you’ll all love.
You can also download the latest issue as a free PDF, so if you’re new to HackSpace, there really is no reason not to give it a go. We know you’re going to love it.
A contractor is drilling in the office space above ours, and it sounds like we’re under attack by a swarm of very angry, Transformeresque bees. We can’t hear ourselves think. Although we can hear the drills.
Because of this disruption, I (Alex) am unable to focus on words. [Ed’s note: me too. We apologies for any typos.] So here you go. Have an interesting video from YouTuber Blitz City DIY.
Can you help Liz create a wireless monitor for her GoPro Hero 6 using VLC on a Raspberry Pi despite the latest changes to GoPro software?
I wanted to create a wireless monitor for my GoPro Hero 6 using VLC on a Raspberry Pi but immediately ran into issues concerning Wi-Fi on the newer GoPro models (basically the GoPro Hero 4 and up).
Reply in the comments of the video, or here if you don’t have a YouTube account. Meanwhile, I will slowly be losing my mind, cowering under my desk with my fingers in my ears.
Quick and simple blog post today: what was your first Raspberry Pi project? Or, if you’ve yet to enter the world of Raspberry Pi ownership, what would you like to do with your Raspberry Pi once you get one?
Answer in the comments below, or on Twitter using #MyFirstRaspberryPi. Photos aren’t necessary, but always welcome (of the project, not of, like, you and your mates in Ibiza circa 2001).
Share your story to receive ten imaginary house points (of absolutely no practical use, but immense emotional value) and a great sense of achievement looking at how far you’ve come.
The latest issue of HackSpace magazine is out today, and it features a rather recognisable piece of tech on the front cover.
From personal computing and electronic fashion to robotics and automatic fabrication, Raspberry Pi is a rather adaptable piece of kit. And whether you choose to use the new Raspberry Pi 4, or the smaller, $5 Raspberry Pi Zero, there are plenty of projects out there for even the most novice of hobbyists to get their teeth into.
This month’s HackSpace magazine, a product of Raspberry Pi Press, is packed full of some rather lovely Raspberry Pi projects, as well as the magazine’s usual features from across the maker community. So, instead of us sharing one of the features with you, as we usually do on release day, we wanted to share them all with you.
Today’s new issue of HackSpace is available as a free PDF download, and, since you’re reading this post, I imagine you’re already a Raspberry Pi fan, so it makes sense you’ll also like this magazine.
So download the free PDF (the download button is below the cover image) and let us know what you think of HackSpace magazine in the comments below.
If you enjoy it and want to read more, you can get a HackSpace magazine subscription or purchase copies from Raspberry Pi Press online store, from the Raspberry Pi store, Cambridge, or from your local newsagent.
As with all our magazines, books, and hardware, every purchase of HackSpace magazine funds the charitable work of the Raspberry Pi Foundation. So if you enjoy this free PDF, please consider purchasing future issues. We’d really appreciate it.