Tag Archives: Raspberry Pi Resources

Ashley’s top five projects for Raspberry Pi first-timers

via 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?

First-timer project 01

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.

First-timer project 02

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.

First-timer project 03

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.

First-timer project 04

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.

First-timer project 05

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.

Don’t forget about Steam Link on Raspberry Pi

via Raspberry Pi

Connect your gaming PC to your TV with ease, thanks to Steam Link and Raspberry Pi.

A Steam Link to the past

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.

And now…

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

The post Don’t forget about Steam Link on Raspberry Pi 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.

How to use a button with a Raspberry Pi

via Raspberry Pi

Here’s our latest How to use video, showing you how to connect a button to your Raspberry Pi.

HOW TO USE a BUTTON with 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…

Connect a button to Raspberry Pi

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.

How to use Raspberry Pi

You’ll find a full list of our current How to use videos here – be sure to subscribe to our channel for more content as we release it.

The post How to use a button with a Raspberry Pi appeared first on Raspberry Pi.

Introducing Raspberry Pi Imager, our new imaging utility

via Raspberry Pi

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.

Raspberry Pi Imager

Simplifying the Raspberry Pi experience

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!

SD cards can be a bit tricky

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?

Introducing the new Raspberry Pi Imager

Image Utility

No Description

From today, Raspberry Pi users will be able to download and use the new Raspberry Pi Imager, available for Windows, macOS and Ubuntu.

Raspberry Pi Imager

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.

Open source and ready to go!

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.

Play Pong with ultrasonic sensors and a Raspberry Pi | HackSpace magazine

via Raspberry Pi

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!

Pong

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 boing-master.

Open a terminal and navigate to this directory, then run:

python3 boing.py

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.

Hacking Code the Classics

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:

import gpiozero

Add this line to instantiate the distance sensor object at the end of the file (just before pgzrun.go()):

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?

Code the Classics

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.