Wikijunior:Raspberry Pi/Introduction to Scratch



Scratch is a visual programming language developed by the Massachusetts Institute of Technology (MIT) to introduce programming concepts to children.

Installing Scratch
Scratch is preinstalled on Raspberry Pi OS (and its predecessor Raspbian) by default.

Online Scratch 3 editor
There is an online editor on the website that can be used for the tutorials which should work on most modern web browsers such as Google Chrome (and its open-source counterpart Chromium), Microsoft Edge, Apple Safari, Opera and Mozilla Firefox.

Offline Scratch 3 editor
Alternatively, you can also download a copy of the offline editor from the official website. Scratch 3 officially supports these operating systems:


 * Windows logo - 2021.svg Microsoft Windows 10 and Windows 11 via the Microsoft Store or direct download
 * Apple logo dark grey.svg Apple macOS 10.13 (High Sierra) and later via the Mac App Store or direct download
 * Google Chrome icon (February 2022).svg Google ChromeOS via the Google Play store
 * Android Robot Head 2023.svg Google Android 6 (Marshmallow) and later via the Google Play store

You can also install Scratch 3 on Windows 10 and Windows 11 via the Winget command in Windows PowerShell:

Alternative Linux distributions
If you use an alternative Linux distribution to Raspberry Pi OS, you may need to install Scratch using the package manager via the Terminal:


 * Ardebian logo.svg Debian and Ubuntu-logo-no-wordmark-solid-o-2022.svg Ubuntu:
 * Fedora logo.svg Fedora:
 * Arch Linux "Crystal" icon.svg Arch:

A simple "Hello World" program
Creating a "Hello World" program in Scratch 3 is very simple:


 * 1) From the Events category, select and drag the yellow "when Greenflag.svg clicked" block.
 * 2) From the Looks category, select and drag the purple "say 'Hello!'" block.
 * 3) Change the text in the purple block from "Hello!" to "Hello World".
 * 4) Click the Go button (with the green flag icon Greenflag.svg) to start the program.

This is equivalent to writing  in the Python programming language.

Moving a sprite
Moving a sprite is essential for making games and other animations. To move a sprite in Scratch, follow these steps:


 * 1) Add a sprite to your project.
 * 2) From the Events category, select and drag the yellow "when Greenflag.svg clicked" block.
 * 3) From the Motion category, select and drag the "move 10 steps" block.
 * 4) Click the Go button (with the green flag icon Greenflag.svg) to start the program.
 * 5) Watch as your sprite moves 10 steps to the right.

You can change the number in the "move 10 steps" block to make your sprite move faster or slower. You can also drag other motion blocks, such as "turn 10 degrees" and "go to x: 100 y: 100", to make your sprite move in different ways.

Making a sprite jump
This is a more advanced Scratch concept, but it's still relatively easy to learn. To make a sprite jump in Scratch, follow these steps:


 * 1) Add a sprite to your project.
 * 2) From the Control category, drag a "when Greenflag.svg clicked" block category to the Scripting Area.
 * 3) From the Control category, drag a "wait 1 second" block to the Scripting Area and place it inside the "when green flag clicked" block.
 * 4) From the Motion category, drag a "change y by 10" block to the Scripting Area and place it inside the "wait 1 second" block.
 * 5) From the Motion category, drag a "change y by -10" block to the Scripting Area and place it below the "wait 1 second" block.
 * 6) Click the Go button (with the green flag icon Greenflag.svg) to start the program.
 * 7) Watch as your sprite jumps into the air and then falls back down.

You can change the number in the "change y by 10" and "change y by -10" blocks to make your sprite jump higher or lower. You can also add more "wait 1 second" blocks to make your sprite stay in the air for longer.