Cheat Sheet

Raspberry Pi For Dummies Cheat Sheet

From Raspberry Pi For Dummies, 2nd Edition

By Sean McManus

The Raspberry Pi is perhaps the most inspiring computer available today. It comes with the tools you need to start making your own software, and you can connect your own electronic inventions to it. It’s different from other computers you’ve used, however, so it can take a little time to get started with it. These tips show you how to discover and install great free software on your Raspberry Pi and how to program in Scratch.

How to Install Games and Other Software on the Raspberry Pi

Lots of free Linux software is available for the Raspberry Pi, and you can install it in two different ways. The most obvious and user-friendly is to use the Pi Store in the desktop environment, but a much wider range of software is available if you use the Linux shell.

Here’s how you can find, download, and install software packages using the shell:

  1. Log in to your Raspberry Pi, but don’t enter the desktop environment.

    Alternatively, if you’re in the desktop environment, double-click the LXTerminal icon to open a shell session.

  2. The first step in installing software is to update the repository, which is the list of packages the package manager knows about. You do that by entering the following command: sudo apt-get update.

    The apt cache contains an index of all the software packages available, and you can search it to find the software you want. For example, you can find all the games by using sudo apt-cache search game | less.

  3. From this listing, find a package you want to install. Each line has the name of a package, a hyphen, and then a description of the package.

  4. Use the up and down cursor keys (or Page Up and Page Down keys) to move through the list of files. Press Q to finish browsing the list.

    In the listing, the bit before the hyphen tells you the name of the package, which is what you need to know to be able to install it. That might not be the same as the game’s title or its popular name.

  5. When you know the name of the package you would like to install, the following command downloads it from the Internet and installs it, together with any other packages it needs to work correctly (known as dependencies): sudo apt-get install penguinspuzzle.

    The last bit (penguinspuzzle) is the name of a package found by searching the cache.

    Your software is now installed! You should be able to run it either from the shell by entering its name (for example, penguinspuzzle), or through your Programs menu in the desktop environment.

Programming in Scratch

The Raspberry Pi was created partly to inspire the next generation of programmers, and Scratch is the perfect place to start. With it, you can make your own cartoons and games and discover some of the concepts that professional programmers use every day.

Scratch is designed to be approachable for people of all ages. The visual interface makes it easy to see what you can do at any time without having to remember any strange codes, and you can rapidly achieve great results. Scratch comes with a library of images and sounds, so it only takes a few minutes to write your first Scratch program.

The Scratch screen layout

Scratch divides the screen into four main areas, as you can see in the following figure. In the top right is the Stage, where you can see your game or animation take shape. There’s a cat on it already, so you can get started straight away by making him do things, as you’ll see in a minute.


The bottom right area is your Sprite List. You can think of sprites as the characters in your game. They’re images that you can make do things, such as move around or change their appearance. For now, there’s just the cat, which has the name Sprite1.

You create a Scratch program by snapping together blocks, which are short instructions. On the left, you can see the Blocks Palette, which currently shows the Motion blocks, which include instructions to move 10 steps, rotate, go to a particular grid reference, and point in a particular direction. Click the colored buttons above the Blocks Palette to show different types of blocks. The blocks are color-coded, which makes it easy for you to find where they are when putting programs together.

The tall middle panel is the Scripts Area. This is where the magic happens! You assemble your program in this space by dragging blocks into it from the left.

Making your sprite move under keyboard control

To make your sprite move under keyboard control, assemble the program in the following figure. You need to click the Control button above the Blocks Palette to view the yellow block, and the Motion button to see the blocks to change the x and y coordinates. The keyboard control block is called when the [space] key is pressed, and you can click where it says [space] to change that to a different key. The blocks to change the x and y position have the number 10 in them by default, but you can click in the box and type your chosen number.


Adding a bouncing ball

There are three New Sprite buttons above the Sprite List (where you see a small picture of a cat). The middle button, which shows a folder on a star, is for choosing a new sprite from a file. Click it and use the file browser to find a ball sprite in the Things folder.

Now you have two sprites in the Sprite List. To choose which one you add blocks to, you click it first. Click the beachball in the Sprite List (not on the Stage) to make sure it’s selected.

Then add the program in the following figure.


When you click the green flag above the Stage to start your program, the ball will start bouncing from left to right and back again, and you can move the cat to try to cross its path without getting hit. Well done! You’ve made your first simple game!

Online Scratch resources

For more help with Scratch, see the following links:

  • Scratch Wiki: The Scratch Wiki is a community resource that includes documentation of all the Scratch blocks. Note that the Raspberry Pi only supports Scratch 1.4, not the more recent Scratch 2.0, so some examples and blocks will not apply.

  • 10 Block Demos: What can you do with Scratch in 10 blocks or fewer? These simple examples by Sean McManus, co-author of Raspberry Pi For Dummies, 2nd Edition, show you how to make a password, make a sprite explode, draw any shape, and more.

  • Debugging Scratch programs: Some tips on the most common bugs in Scratch programs and how you can find them.

  • Code Club Scratch Projects: Code Club provides project tutorials that are typically used in schools, but you can use them at home too.

  • ScratchEd: A site for educators that includes lots of links to example Scratch projects and other resources.