Tag Archives: Publications

Raspberry Pi Christmas Shopping Guide 2020

via Raspberry Pi

The most wonderful time of the year is approaching! “Most wonderful” meaning the time when you have to figure out what gift best expresses your level of affection for various individuals in your life. We’re here to take away some of that stress for you — provided your favourite individuals like Raspberry Pi, of course. Otherwise you’re on your own. Sorry.

We’ve got ideas for the gamers in your life, what to get for the Raspberry Pi “superfan” who has everything, and options that allow you to keep giving all year round.

Newest and hottest

If keeping up with the Joneses is your thing, why not treat your nearest Raspberry Pi fan to one of our newest products…

Raspberry Pi 400 | $70

Top view of a woman's hands using the Raspberry Pi 400 keyboard and official Raspberry Pi mouse

This year, we released Raspberry Pi 400: a complete personal computer, built into a compact keyboard, costing just $70. Our community went wild about the possibilities that Raspberry Pi 400 opens up for home learners and for those who don’t have expensive tech options at their fingertips.

You just plug in a mouse, a monitor (any semi-modern TV screen should work), and go. The Raspberry Pi 400 Personal Computer kit costs $100 and comes with a few extras to help get you started. Or you can buy the Raspberry Pi 400 unit on its own.

Depending on where you are in the world, you may need to pre-order or join a waiting list, as Raspberry Pi 400 is in such high demand. But you could give a homemade ‘IOU’ voucher letting the recipient know that they will soon get their hands on one of our newest and most popular bits of kit.

Our latest book of coding coolness | £10

We publish some cool books around these parts. Laura Sach and Martin O’Hanlon, who are both Learning Managers at the Raspberry Pi Foundation, have written the very newest one, which is designed to help you to get more out of your Python projects.

In Create Graphical User Interfaces with Python, you’ll find ten fun Python projects to create, including a painting program, an emoji match game, and a stop-motion animation creator. All for just £10.

So, if you’ve a keen coder in your midst, this book is the best choice to stretch their skills and keep them entertained throughout 2021. Buy it online from the official Raspberry Pi Press store.

Gamers

Raspberry Pi 4 Retro Gaming Kit | £88

Lovely image courtesy of The Pi Hut

The Pi Hut’s Raspberry Pi 4 Retro Gaming Kit costs £88 and includes everything you need to create your very own retro gaming console. All your lucky kit recipient has to find is a screen to plug into, and a keyboard to set up their new Raspberry Pi, which comes as part of the kit along with a case for it. The Pi Hut has also thrown in a 16GB microSD card, plus a reader for it, as well as our official micro HDMI cable. Job done.

Picade 8″ or 10″ display | from £165

Pretty picture courtesy of Pimoroni

How cool does Picade look?! It’s sold by Pimoroni and you can buy an 8″ display set for £165, or a 10″ display version for £225. Show me a self-respecting gamer who doesn’t want a desktop retro arcade machine in their own home.

Picade is a Raspberry Pi–powered mini arcade that you build yourself. All you’ll need to add is your own Raspberry Pi, a power supply, and a micro SD card.

Code the Classics, Volume 1 | £12

And if the gamer on your gift list prefers to create their own retro video games, send them a copy of Code the Classics, Volume 1. It’s a stunning-looking hardback book packed with 224 pages telling the stories of some of the seminal video games of the 1970s and 1980s, and showing you how to create your own. Putting hours of projects in the hands of your favourite gamer will only set you back £12. Buy it online from the official Raspberry Pi Press store.

Raspberry Pi superfans

Raspberry Pi Zero W | $10

For just $10 apiece, you can drop a couple Raspberry Pi Zero W into any tinkerer’s stocking and they’ll be set for their next few projects. They will LOVE you for allowing them try a new, risky build without having to tear down something else they created to retrieve an old Raspberry Pi.

Babbage Bear | $9

What to get the superfan who already has a desk full of Raspberry Pi? An official Babbage Bear to oversee the proceedings! Babbage only costs £9 and will arrive wearing their own Raspberry Pi–branded T-shirt. A special Raspberry Pi Towers inhabitant made our Babbage this Christmassy outfit before we photographed them.

Official t-shirts | $12

If you’ve a superfan on your gift list, then it’s likely they already own a t-shirt with the Raspberry Pi logo on it — so why not get them one of these new designs?

Both costing just £12, the black Raspberry Pi “Pi 4” t-shirt was released to celebrate the launch of Raspberry Pi 4 and features an illustration of the powerful $35 computer. The white Raspberry Pi “Make Cool Stuff” option was created by Raspberry Pi’s own illustrator/animator extraordinaire Sam Alder. Drop that inside fact on the gift tag for extra superfan points.

Wearable tech projects | £7

And if they’re the kind of superfan who would like to make their own Raspberry Pi-–themed clothing, gift them with our Wearable Tech Projects book. This 164-page book gathers up the best bits of wearable technology from HackSpace magazine, with tutorials such as adding lights to your favourite cosplay helmet, and creating a glowing LED skirt. It’s on sale for just £7 and you can buy it online from the official Raspberry Pi Press store.

Keep giving all year

What if you could give the joy of opening a Raspberry Pi–themed gift every single month for a whole year? Our magazine subscriptions let you do just that, AND they come with a few extra gifts when you sign up.

The MagPi magazine

The official Raspberry Pi magazine comes with a free Raspberry Pi Zero kit worth £20 when you sign up for a 12-month subscription. The magazine is packed with computing and electronics tutorials, how-to guides, and the latest news and reviews.

Check out subscription deals on the official Raspberry Pi Press store.

HackSpace magazine

HackSpace magazine is packed with projects for fixers and tinkerers of all abilities. 12-month subscriptions comes with a free Adafruit Circuit Playground Express, which has been specially developed to teach programming novices from scratch and is worth £25.

Check out subscription deals on the official Raspberry Pi Press store

Wireframe magazine

Wireframe magazine lifts the lid on video games. In every issue, you’ll find out how games are made, who makes them, and how you can make your own using detailed guides. The latest deal gets you three issues for just £10, plus your choice of one of our official books as a gift.

Check out more subscriptions deals on the official Raspberry Pi Press store.

Custom PC

Custom PC is the magazine for people who are passionate about PC technology and hardware. You can subscribe to receive three issues for just £10, and you’ll also receive a book as a gift.

Check out subscription offers on the official Raspberry Pi Press store.

That’s all folks. Have a holly jolly one. Drop a question in the comments box below if you’re after something Raspberry Pi–themed which isn’t mentioned here. I’m half elf and should be able to help.

The post Raspberry Pi Christmas Shopping Guide 2020 appeared first on Raspberry Pi.

New book: Create Graphical User Interfaces with Python

via Raspberry Pi

Laura Sach and Martin O’Hanlon, who are both Learning Managers at the Raspberry Pi Foundation, have written a brand-new book to help you to get more out of your Python projects.

Cover of the book Create Graphical User Interfaces with Python

In Create Graphical User Interfaces with Python, Laura and Martin show you how to add buttons, boxes, pictures, colours, and more to your Python programs using the guizero library, which is easy to use and accessible for all, no matter your Python skills.

This new 156-page book is suitable for everyone — from beginners to experienced Python programmers — who wants to explore graphical user interfaces (GUIs).

Meet the authors

Screenshot of a Digital Making at Home live stream session
That’s Martin in the blue T-shirt with our Digital Making at Home live stream hosts Matt and Christina

You might have met Martin recently on one of our weekly Digital Making at Home live streams for young people, were he was a guest for an ‘ooey-GUI’ code-along session. He talked about his background and what it’s like creating projects and learning resources on a day-to-day basis.

Laura is also pretty cool! Here she is showing you how to solder your Raspberry Pi header pins:

Hi Laura!

Martin and Laura are also tonnes of fun on Twitter. You can find Martin as @martinohanlon, and Laura goes by @codeboom.

10 fun projects

In Create Graphical User Interfaces with Python, you’ll find ten fun Python projects to create with guizero, including a painting program, an emoji match game, and a stop-motion animation creator.

A double-page from the book Create Graphical User Interfaces with Python
A peek inside Laura’s and Martin’s new book

You will also learn:

  • How to create fun Python games and programs
  • How to code your own graphical user interfaces using windows, text boxes, buttons, images, and more
  • What event-based programming is
  • What good (and bad) user interface design is
A double-page from the book Create Graphical User Interfaces with Python
Ain’t it pretty?

Where can I get it?

You can buy Create Graphical User Interfaces with Python now from the Raspberry Pi Press online store, or the Raspberry Pi store in Cambridge, UK.

And if you don’t need the lovely new book, with its new-book smell, in your hands in real life, you can download a PDF version for free, courtesy of The MagPi magazine.

The post New book: Create Graphical User Interfaces with Python appeared first on Raspberry Pi.

New book: The Official Raspberry Pi Camera Guide

via Raspberry Pi

To coincide with yesterday’s launch of the Raspberry Pi High Quality Camera, Raspberry Pi Press has created a new Official Camera Guide to help you get started and inspire your future projects.

The Raspberry Pi High Quality Camera

Connecting a High Quality Camera turns your Raspberry Pi into a powerful digital camera. This 132-page book tells you everything you need to know to set up the camera, attach a lens, and start capturing high-resolution photos and video footage.

Make those photos snazzy

The book tells you everything you need to know in order to use the camera by issuing commands in a terminal window or via SSH. It also demonstrates how to control the camera with Python using the excellent picamera library.

You’ll discover the many image modes and effects available – our favourite is ‘posterise’.

Build some amazing camera-based projects

Once you’ve got the basics down, you can start using your camera for a variety of exciting Raspberry Pi projects showcased across the book’s 17 packed chapters. Want to make a camera trap to monitor the wildlife in your garden? Build a smart door with a video doorbell? Try out high-speed and time-lapse photography? Or even find out which car is parked in your driveway using automatic number-plate recognition? The book has all this covered, and a whole lot more.

Don’t have a High Quality Camera yet? No problem. All the commands in the book are exactly the same for the standard Raspberry Pi Camera Module, so you can also use this model with the help of our Official Camera Guide.

Snap it up!

The Official Raspberry Pi Camera Guide is available now from the Raspberry Pi Press online store for £10. And, as always, we have also released the book as a free PDF. But the physical book feels so good to hold and looks so handsome on your bookshelf, we don’t think you’ll regret getting your hands on the print edition.

Whichever format you choose, have fun shooting amazing photos and videos with the new High Quality Camera. And do share what you capture with us on social media using #ShotOnRaspberryPi.

The post New book: The Official Raspberry Pi Camera Guide appeared first on Raspberry Pi.

Build low-power, clock-controlled devices

via Raspberry Pi

Do you want to make a sensor with a battery life you can measure in days rather than hours? Even if it contains a (relatively!) power-hungry device like a Raspberry Pi? By cunning use of a real-time clock module, you can make something that wakes up, does its thing, and then goes back to sleep. While asleep, the sensor will sip a tiny amount of current, making it possible to remotely monitor the temperature of your prize marrow in the greenhouse for days on end from a single battery. Read on to find out how to do it.

A sleeping Raspberry Pi Zero apparently consuming no current!

You’ll need:

  • DS3231 powered real-time clock module with battery backup: make sure it has a battery holder and an INT/SQW output pin
  • P-channel MOSFET: the IRF9540N works well
  • Three resistors: 2.2 kΩ, 4.7 kΩ, and 220 Ω
  • A device you want to control: this can be a PIC, Arduino, ESP8266, ESP32, or Raspberry Pi. My software is written in Python and works in MicroPython or on Raspberry Pi, but you can find DS3231 driver software for lots of devices
  • Sensor you want to use: we’re using a BME280 to get air temperature, pressure, and humidity
  • Breadboard or prototype board to build up the circuit

We’ll be using a DS3231 real-time clock which is sold in a module, complete with a battery. The DS3231 contains two alarms and can produce a trigger signal to control a power switch. To keep our software simple, we are going to implement an interval timer, but there is nothing to stop you developing software that turns on your hardware on particular days of the week or days in the month. The DS3231 is controlled using I2C, which means it can be used with lots of devices.

You can pick up one of these modules from lots of suppliers. Make sure that you get one with the SQW connection, as that provides the alarm signal

MOSFET accompli

The power to our Raspberry Pi Zero is controlled via a P-channel MOSFET device operating as a switch. The 3.3 V output from Raspberry Pi is used to power the DS3231 and our BME280 sensor. The gate on the MOSFET is connected via a resistor network to the SQW output from the DS3231.

You can think of a MOSFET as a kind of switch. It has a source pin (where we supply power), a drain pin (which is the output the MOSFET controls), and a gate pin. If we change the voltage on the gate pin, this will control whether the MOSFET conducts or not.

We use a P-channel MOSFET to switch the power because the gate voltage must be pulled down to cause the MOSFET to conduct, and that is how P-channel devices function.

MOSFET devices are all about voltage. Specifically, when the voltage difference between the source and the gate pin reaches a particular value, called the threshold voltage, the MOSFET will turn on. The threshold voltage is expressed as a negative value because the voltage on the gate must be lower than the voltage on the source. The MOSFET that we’re using turns on at a threshold voltage of around -3.7 volts and off at a voltage of -1.75 volts.

The SQW signal from the DS3231 is controlled by a transistor which is acting as a switch connected to ground inside the DS3231. When the alarm is triggered, this transistor is turned on, connecting the SQW pin to ground. The diagram below shows how this works.

The resistors R1 and R2 are linked to the supply voltage at one end and the SQW pin and the MOSFET gate on the other. When SQW is turned off the voltage on the MOSFET gate is pulled high by the resistors, so the MOSFET turns off. When SQW is turned on, it pulls the voltage on the MOSFET gate down, turning it on.

Unfortunately, current leaking through R1 and R2 to the DN3231 means that we are not going to get zero current consumption when the MOSFET is turned off, but it is much less than 1 milliamp.

We’re using a BME280 environmental sensor on this device. It is connected via I2C to Raspberry Pi. You don’t need this sensor to implement the power saving

Power control

Now that we have our hardware built, we can get some code running to control the power. The DS3231 is connected to Raspberry Pi using I2C. Before you start, you must enable I2C on your Raspberry Pi using the raspi-config tool. Use sudo raspi-config and select Interfacing Options. Next, you need to make sure that you have all the I2C libraries installed by issuing this command at a Raspberry Pi console:

sudo apt-get install python3-smbus python3-dev i2c-tools

The sequence of operation of our sensor is as follows:

  1. The program does whatever it needs to do. This is the action that you want to perform at regular intervals. That may be to read a sensor and send the data onto the network, or write it to a local SD card or USB memory key. It could be to read something and update an e-ink display. You can use your imagination here.
  2. The program then sets an alarm in the DS3231 at a point in the future, when it wants the power to come back on.
  3. Finally, the program acknowledges the alarm in the DS3231, causing the SQW alarm output to change state and turn off the power.

Clock setting

The program below only uses a fraction of the capabilities of the DS3231 device. It creates an interval timer that can time hours, minutes, and seconds. Each time the program runs, the clock is set to zero, and the alarm is configured to trigger when the target time is reached.

Put the program into a file called SensorAction.py on your Raspberry Pi, and put the code that you want to run into the section indicated.

import smbus

bus = smbus.SMBus(1)

DS3231 = 0x68

SECONDS_REG = 0x00
ALARM1_SECONDS_REG = 0x07

CONTROL_REG = 0x0E
STATUS_REG = 0x0F

def int_to_bcd(x):
    return int(str(x)[-2:], 0x10)

def write_time_to_clock(pos, hours, minutes, seconds):
    bus.write_byte_data(DS3231, pos, int_to_bcd(seconds))
    bus.write_byte_data(DS3231, pos + 1, int_to_bcd(minutes))
    bus.write_byte_data(DS3231, pos +2, int_to_bcd(hours))

def set_alarm1_mask_bits(bits):
    pos = ALARM1_SECONDS_REG
    for bit in reversed(bits):
        reg = bus.read_byte_data(DS3231, pos)
        if bit:
            reg = reg | 0x80
        else:
            reg = reg & 0x7F
        bus.write_byte_data(DS3231, pos, reg)
        pos = pos + 1

def enable_alarm1():
    reg = bus.read_byte_data(DS3231, CONTROL_REG)
    bus.write_byte_data(DS3231, CONTROL_REG, reg | 0x05)

def clear_alarm1_flag():
    reg = bus.read_byte_data(DS3231, STATUS_REG)
    bus.write_byte_data(DS3231, STATUS_REG, reg & 0xFE)

def check_alarm1_triggered():
    return bus.read_byte_data(DS3231, STATUS_REG) & 0x01 != 0

def set_timer(hours, minutes, seconds):
    # zero the clock
    write_time_to_clock(SECONDS_REG, 0, 0, 0)
    # set the alarm
    write_time_to_clock(ALARM1_SECONDS_REG, hours, minutes, seconds)
    # set the alarm to match hours minutes and seconds
    # need to set some flags
    set_alarm1_mask_bits((True, False, False, False))
    enable_alarm1()
    clear_alarm1_flag()

#
# Your sensor behaviour goes here
#
set_timer(1,30,0)

The set_timer function is called to set the timer and clear the alarm flag. This resets the alarm signal and powers off the sensor. The example above will cause the sensor to shut down for 1 hour 30 minutes.

You can use any other microcontroller that implements I2C

Power down

The SensorAction program turns off your Raspberry Pi without shutting it down properly, which is something your mother probably told you never to do. The good news is that in extensive testing, we’ve not experienced any problems with this. However, if you want to make your Raspberry Pi totally safe in this situation, you should make its file system ‘read-only’, which means that it never changes during operation and therefore can’t be damaged by untimely power cuts. There are some good instructions from Adafruit here: hsmag.cc/UPgJSZ.

Note: making the operating system file store read-only does not prevent you creating a data logging application, but you would have to log the data to an external USB key or SD card and then dismount the storage device before killing the power.

If you are using a different device, such as an ESP8266 or an Arduino, you don’t need to worry about this as the software in them is inherently read-only.

The SQW output from the DS3231 will pull the gate of the MOSFET low to turn on the power to Raspberry Pi

Always running

To get the program to run when the Raspberry Pi boots, use the Nano editor to add a line at the end of the rc.local file that runs your program.

sudo nano /etc/rc.local

Use the line above at the command prompt to start editing the rc.local file and add the following line at the end of the file:

python3 /home/pi/SensorAction.py &

This statement runs Python 3, opens the SensorAction.py file, and runs it. Don’t forget the ampersand (&) at the end of the command: this starts your program as a separate process, allowing the boot to complete. Now, when Raspberry Pi boots up, it will run your program and then shut itself down. You can find a full sample application on the GitHub pages for this project (hsmag.cc/Yx7q6t). It logs air temperature, pressure, and humidity to an MQTT endpoint at regular intervals. Now, go and start tracking that marrow temperature!

Issue 30 of HackSpace magazine is out now

The latest issue of HackSpace magazine is on sale now, and you can get your copy from the Raspberry Pi Press online store. You can also download it for free to check it out first.

UK readers can take advantage of our special subscriptions offer at the moment.

3 issues for £10 & get a free book worth £10…

If you’re in the UK, get your first three issues of HackSpace magazine, The MagPi, Custom PC, or Digital SLR Photography delivered to your door for £10, and choose a free book (itself worth £10) on top!

The post Build low-power, clock-controlled devices appeared first on Raspberry Pi.

Special offer for magazine readers

via Raspberry Pi

You don’t need me to tell you about the unprecedented situation that the world is facing at the moment. We’re all in the same boat, so I won’t say anything about it other than I hope you stay safe and take care of yourself and your loved ones.

The other thing I will say is that every year, Raspberry Pi Press produces thousands of pages of exciting, entertaining, and often educational content for lovers of computing, technology, games, and photography.

In times of difficulty, it’s not uncommon for people to find solace in their hobbies. The problem you’ll find yourself with is that it’s almost impossible to buy a magazine at the moment, at least in the UK: most of the shops that sell them are closed (and even most of their online stores are too).

We’re a proactive bunch, so we’ve done something about that:

From today, you can subscribe to The MagPi, HackSpace magazine, Custom PC, or Digital SLR Photography at a cost of three issues for £10 in the UK – and we’re giving you a little extra too.

We like to think we produce some of the best-quality magazines on the market today (and you only have to ask our mums if you want a second opinion). In fact, we’d go as far as to say our magazines are exactly the right mix of words and pictures for making the most of all the extra home-time you and your loved ones are having.

Take your pick for three issues at £10 and get a free book worth £10!

If you take us up on this offer, we’ll send the magazines direct to your door in the UK, with free postage. And we’re also adding a gift to thank you for signing up: on top of your magazines, you’ll get to choose a book that’s worth £10 in itself.

In taking up this offer, you’ll get some terrific reading material, and we’ll deliver it all straight to you — no waiting around. You’ll also be actively supporting our print magazines and the charitable work of the Raspberry Pi Foundation.

I hope that among our magazines, you’ll find something that’s of interest to you or, even better yet, something that sparks a new interest. Enjoy your reading!

The post Special offer for magazine readers appeared first on Raspberry Pi.

Build a physical game controller for Infinite Bunner

via Raspberry Pi

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.

Infinite Bunner

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 flick controller

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.

Playing Infinite Bunner

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:

python3 bunner.py

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 cp
x, 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.

HackSpace magazine is out now

The latest issue of HackSpace magazine is out today and can be purchased from the Raspberry Pi Press online store. You can also download a copy if you want to see what all the fuss is about.

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:

Code the Classics: Artist Dan Malone

No Description

The post Build a physical game controller for Infinite Bunner appeared first on Raspberry Pi.