Getting Started with Scratch on the Raspberry Pi?

Scratch is a block-based visual programming language developed by MIT Media Lab to teach coding concepts to children and beginners. With Scratch, you can create interactive stories, games, animations, and more. The Raspberry Pi is a series of small, affordable computers that are often used to learn programming. By installing Scratch on a Raspberry Pi, you can start coding games and applications right on your own personal computer!

Getting Started with Scratch on the Raspberry Pi?

What You Will Need

To follow along with this guide, you will need:

  • A Raspberry Pi computer (any model will work)
  • A monitor or TV to connect to the Raspberry Pi
  • A microSD card with Raspbian (the Pi’s operating system) installed
  • A mouse and keyboard to interact with the Raspberry Pi
  • An internet connection to download Scratch

Don’t worry if you are completely new to Raspberry Pis – we will provide detailed steps on setting up the Raspberry Pi as well.

Step 1 – Set Up the Raspberry Pi

The first step is to get your Raspberry Pi up and running with Raspbian.

Here is a quick checklist of what you need to do:

  • Connect the Raspberry Pi to a monitor with an HDMI cable
  • Connect a keyboard and mouse to USB ports
  • Insert the microSD card with Raspbian into the Pi
  • Connect the Pi to power to turn it on
  • Complete the initial Raspbian setup prompts

Once your Raspberry Pi boots into the Raspbian desktop, you are ready to install Scratch.

Step 2 – Download and Install Scratch

  1. Open the terminal app on the Raspberry Pi desktop
  2. Type the following command and press Enter:

sudo apt-get update

  1. Once the update completes, install Scratch with this command:

sudo apt-get install scratch -y

Wait for Scratch to finish installing. Once complete, you can launch Scratch from the Application Menu under Programming.

The first time you open Scratch, you’ll see the blank Scratch programming environment with an interactive sprite (the Scratch cat). Now you are ready to start coding with blocks!

Step 3 – Getting Familiar with the Scratch Interface

The Scratch interface consists of a few key areas:

  • Sprite Area – The sprite area displays all current sprites for your project. You can have multiple sprites that interact with each other.
  • Blocks Palette – The blocks palette contains all the coding block pieces that you can snap together to program your sprites.
  • Scripting Area – This is where you snap blocks together from the palette to build the programming scripts that make your sprites do things.
  • Stage – The Stage displays the outputs of your program. All sprites are programmed to interact on the Stage.

Let’s get familiar with programming with blocks by making the sprite say “Hello!” when clicking on it.

  1. Click on the default cat sprite in the sprite area
  2. In the blocks palette, click Events. Drag out a When this sprite clicked block into the scripting area.
  3. From the Looks palette, drag out a Say Hello! for 2 seconds block and connect it to the first block.
  4. Click on the sprite on the stage. You should see the text greet you!

That’s all it takes to put together scripts with Scratch’s visual block coding method. Next, let’s go over some key coding concepts.

Step 4 – Understanding Key Coding Concepts

As you start building projects in Scratch, there are some important programming concepts that are good to understand:


A script a series of connected blocks that make a sprite do something. Scripts are triggered by Events. For example, when clicking on a sprite, when pressing a key, when receiving a broadcast message, etc.


Events cause scripts to execute. Common events include when clicking on sprites, key presses, messages received, loading the project, etc.


Loops allow you to repeat a section of code multiple times without needing to duplicate it. The Repeat block lets you input how many times to loop.


Variables store data that can change over the course of a program. For example, variables can be used to store scores, player lives, or anything else that needs to be tracked.


Conditionals allow your program to make decisions and react differently based on conditions. The If/Else conditional blocks let you execute different code based on whether a statement is True or False.


Inputs allow users to provide data to your program with their keyboard, mouse, or microphone. The Ask block prompts the user to input text or numbers.

These are just a few programming concepts you will use often when coding in Scratch. For more information, see Scratch’s coding concepts documentation.

Step 5 – Making Your First Scratch Game

Now that you know the basics, let’s put your skills to work by creating a simple game!

We will build a basketball game where you can move a character with the arrow keys to catch bouncing balls in a net.

Follow along below or remix this starter project to load our assets to get started!

  1. Choose a backdrop – Click the Stage icon, select a suitable backdrop like basketball court.
  2. Create sprites – Make 2 new sprites by clicking the cat icon:
    • A baller sprite (we created one named “Jordan”)
    • A basketball sprite
  3. Animate the baller – Go to the baller’s Costumes tab:
    • Upload costume images showing walking animation frames
    • Add the switch costume to blocks to animate between images
  4. Make the ball bounce – Go to the ball Sprite. From the purple Motion blocks:
    • Add Point in direction block connected to Pick random number between (30 to 150)
    • Add a Forever loop around a sequence of:
      • Move 10 steps
      • If on edge, bounce block
  5. Control the baller – Back in the baller Sprite:
    • Add key press Events to run scripts
    • Add Point in direction and Move 10 steps blocks to show arrow keys control movement
  6. Detect catching balls – From the green Sensing blocks:
    • Add an If touching Basketball check inside a Forever loop
    • Add blocks to increase score by 1 point and play sounds when a ball is caught!
  7. Add More Features – Enhance as desired:
    • Variable blocks to show an updating score
    • Conditions to end game
    • Inputs to get player names
    • Anything you can imagine!

That covers the basics of making an interactive game in Scratch. The key is to start with ideas for sprites and their behaviors, then piece together scripts with Events, Motion, Looks, Control, and Sensing blocks.

With Scratch’s visual approach, you have the building blocks you need for any type of project you can dream up!

Key Takeaways

  • Scratch teaches coding concepts like scripts, conditionals, and variables through easy drag-and-drop blocks
  • Install Scratch on a Raspberry Pi to start scripting your own interactive animations and games
  • Understand concepts like Events, Loops, Variables, Conditionals, and Inputs to build scripts
  • Construct projects by choosing backdrops and sprites, then programming behaviors with blocks
  • Publish and share your games and creations online with the Scratch community

By learning Scratch on a Raspberry Pi, you now have a platform to let your creativity run wild!


We have covered everything you need to start your journey with Scratch on the Raspberry Pi, from installing and navigating the interface to understanding key coding concepts. With Scratch’s infinite possibilities, you can create all kinds of stories, animations, games, music, art, and more.

Where you go next is up to you! Look over example projects for inspiration. Review coding concepts like Events, Data, Control, Looks, and Sound to expand your programming toolbox. Use the Raspberry Pi’s inputs like the camera module or GPIP pins to interact with real-world devices.

Most importantly, explore, experiment, and express yourself as you learn how technology can become an extension of your imagination.

The Scratch community is there to help with any questions or ideas you want to bring to life with code. Have fun creating with Scratch on your Raspberry Pi!

Frequently Asked Questions 

  1. Do you need to know programming before using Scratch?
    No programming experience is required to start with Scratch! The drag-and-drop block approach lets beginners easily piece together code without needing to manually type syntax. Scratch’s hands-on method helps develop programming concepts through visual building instead of complex code.
  2. Can Scratch run on any Raspberry Pi models?
    Yes, Scratch is compatible with all generations of Raspberry Pi boards, including Pi Zero, Pi 3, Pi 4, Pi 400, and more. As long as the Raspberry Pi can run a recent version of Raspbian operating system, Scratch will install and run smoothly.
  3. Where do I write code in Scratch?
    You snap together Scratch code blocks in the Script Area. Click and drag from blocks categories like Events, Control, Motion to connect programming logic. All scripts attached to a sprite will execute to have the sprite react, move, or alter the screen.
  4. How do I get characters and backgrounds in Scratch?
    Scratch includes libraries of characters and backdrops to use. Click the default cat sprite to change it into hundreds of available objects. Click the background to select alternate scenes built into Scratch. You can also paint your own sprites, upload images, or use the webcam to add anything you want!
  5. How do I save my Scratch projects?
    In Scratch, you save creations right in your browser locally by hitting the Disk icon next to the green flag. Name your project and reload to return to it. Sign up for an account to save projects permanently online on Scratch’s servers.
  6. Can I use Scratch offline?
    The browser-based Scratch 3 does require an internet connection initially to load the editor, sprite libraries, sounds, and other assets. After loading once online, Chrome and Firefox let you then use Scratch with no internet by enabling offline modes in Scratch’s settings. Scratch also offers free Android and iOS apps for mobile creation offline!
  7. Can I make money creating Scratch games?
    Scratch is meant for learning over commercial projects, but the skills to design games and animations can certainly lead to professional opportunities. Many creators use Scratch to prototype ideas before building out development studios and selling interactive media products commercially.
  8. Can I use Scratch on my tablet or smartphone?
    Yep, Scratch 3’s editor features a responsive design to work on any modern device size, including mobile screens and tablets. Scratch also provides Android and iOS apps to create on the go without a browser. Features are currently limited compared to the desktop, but mobile Scratch ports keep improving all the time.
  9. Is Scratch safe for kids to use?
    Scratch prioritizes child safety in all aspects of its platform. Accounts and sharing projects requires parental permission under 13 years old. Moderation teams carefully filter content and imagery deemed inappropriate. Scratch also takes care to meet stringent data privacy rules regarding minors like COPPA in the United States.
  10. Are there text programming options too?
    For users wanting to transition to typed code, Scratch allows switching into Text Mode to view the JavaScript run behind blocks. Developers can also use extensions like Scratch Blocks to generate text code equivalents for applications like Python for older learners.
  11. Can I connect hardware like Lego or Arduino to Scratch?
    A huge part of Scratch’s functionality involves integrating hardware devices like motors, sensors, controllers, lights, and robots. Extensions like LEGO WeDo, Pico Board, or micro: bit allow kids to program their electronics creations right within Scratch’s interface!
  12. What are some fun first projects to try in Scratch?
    Some fun starter ideas in Scratch that quickly let kids see results include simple animations, interactive birthday cards, maze navigators, jumping over obstacles, knock knock joke generators, pulling pranks on sprites, quiz games, recreating songs using sounds, and anything involving their favorite cartoons!
  13. What age is appropriate to introduce my child to Scratch?
    Scratch targets ages 8-16 but has no limits. Preschoolers can understand basic sequencing by snapping blocks together. Elementary schoolers can build interactive tales around subjects they’re studying. High schoolers create intricate simulations and experiments. Scratch is intended to grow along with any student’s evolving capabilities over years.
  14. Can Scratch run on a Raspberry Pi Zero?
    Of course, Scratch works excellently on the ultra compact Pi Zero and Pi Zero 2 models, running smoothly even on these low processing power devices. Combining hands-on physical computing on Pi Zero with easy access coding through Scratch makes for an incredibly fun STEM learning system!
  15. What projects can I make by connecting Scratch to a Raspberry Pi camera?
    Connecting a Raspberry Pi camera module opens exciting real-time interactive options, like taking selfies and effects, building obstacle avoiding robots, detecting colors and objects, tracking motion and speeds, classifying image content with machine learning, monitoring pets or wildlife with wildlife camera trigging, and anything involving computer vision!

Leave a Comment