Blog  /  Raspberry Pi Scratch: Coding in Raspberry Pi

Raspberry Pi Scratch: Coding in Raspberry Pi

Scratch programming language allows people from all backgrounds to create interactive projects and share with other people from all walks of life. In addition, working with Raspberry Pi Scratch helps you design code that enables you to interact and regulate modules integrated into Pi’s GPIO pins. Therefore, coding with Raspberry Pi makes your scratch developments more appealing. In this article, you will learn ways of getting started with Scratch, including various amazing projects for Raspberry Pi.  

What is Scratch?

  Scratch is an elite visual programing language designed mainly for beginners, allowing them to produce their animations, art, games, and interactive stories. The site user (scratchers) uses a block-like interface to create impressive IoT projects on the website. Besides external tools, they can export the projects to EXE files, Android apps, JavaScript, and HTML. Furthermore, using block-based coding, once the user creates GPIO projects, they can share them with others. Therefore, Scratch is an ideal tool for teaching coding to the young ones, especially remotely.  
Set of drivers, diodes, capacitors, inductance, and other microelectronics

Set of drivers, diodes, capacitors, inductance, and other microelectronics

 

What Can I Do with Scratch 3 and Raspberry Pi?

  Scratch 3 is the newest scratch model, with notably enhanced functionality and heightened interface. Besides, it features new extensions enabling you to regulate sense HAT and GPIO pins with scratch complete code. There is so much you can do with Scratch and Raspberry Pi, including:  

Sense HAT Extension

  The updated Sense HAT extension features new elements allowing benefit from Scratch 3 new features. Hence, the new block gives you the ability to;
  • Provide Demonstration of designs, typescripts, and texts within the LED environment
  • Estimate moistness, pressure, and hotness
  • Apply the touchpad
  • Recognize alignment, trembling, and slanting
 
Extension cable

Extension cable

 

Simple Electronic Extension

  The friendliest extension for beginners is a simple electronic component when networking with Raspberry Pi’s GPIO pins. Furthermore, it's the best option, especially when searching for something modest to complement the game, like a switching regulator or LED.  

GPIO Extension

  The functionality and outline of the GPIO extension resemble the current Scratch 2 extension. Therefore, users can apply it as a pop-in substitution. Besides, the Raspberry Pi GPIO extension offers users the mutability to direct control and unite numerous electrical modules.  

Micro: bit and LEGO Extensions

  Unlike Raspbian, micro: bit isn’t offered for Linux-type operational networks at the moment. The reason is that the Scratch connection program lets Scratch interact with Bluetooth modules that aren’t installed. Nevertheless, it will be offered on the Scratch 3 Desktop version in the near future.  
Extension cable

Arduino control broad element photo with infographic details

 

Getting Started with Scratch on the Raspberry Pi

  In this tutorial, we will demonstrate how to get started with Scratch on the Raspberry Pi. In addition, we will show exactly how to set up this software on Raspberry. Note that we will run a new version of Raspbian containing a desktop interface.  

Equipment Required

 
  • HDMI Cable
  • Power Supply
  • Raspberry Pi
  • Monitor
  • USB Mouse
  • Micro SD Card
  • USB Keyboard
  • Ethernet Cable or Wi-Fi
Optional  

Scratch Installation to the Raspberry Pi

  If running Raspian Desktop, note that some Raspbian comes with pre-installed Scratch software. Therefore, if you have it, you can skip this section.  
Raspberry Pi 2 Model B

Raspberry Pi 2 Model B

  Step 1   Begin by updating the operating system before Scratch installation to our Raspberry. Run these two commands to upgrade the existing packages.  
  Step 2   Afterward, run the following order to complete the Scratch installation process.  
  After a successful download, figure out how to open Scratch on Raspberry Pi.  

Opening Scratch

  Step 1   On the screen right corner, you will find the Raspberry icon. Hence, click on its symbol to open the start menu.   Step 2   After opening the menu, go to the “Programming” menu. Click on the drop-down taskbar and choose the “Scratch” option.   Step 3   Once you have chosen that option, Scratch will now open on the Pi, and you can now use the software.  

Finish the Setup

 
  • Connect your Pi to a Wi-Fi network
  • Configure the password for the Pi
  • Set up time zone, language, and country
  • Install all required updates
 

Updating the OS to Raspbian Buster

  Begin by opening the terminal window. On the desktop's top left side, click on the black square symbol to open the terminal window. Type the following command on the terminal window.  
  Afterward, once prompted, type the following;  
  Finally, you will get y/n type y and go back. You will now have updated your Raspberry Pi operating system to Rasbpian Buster. Note that the process will take around 10 to 15 minutes to complete. Once it's complete, run the following command to reboot the Pi.  
 

Troubleshooting

  In a few cases, you might find that your screen doesn’t show output from the Raspberry Pi. First, ensure all the connections are in place before restarting the Pi. Secondly, ensure the SD card has NOOBS properly connected. With everything set up, you only need to get Scratch up and running.  

Using the Scratch to Connect to the World

  Even though it’s not a must to have a Raspberry Pi for using and running the Scratch, the Pi unlocks numerous other competencies. Furthermore, linking it to the Raspberry Pi allows us to make good use of “GPIO” pins, making the Scratch program interrelate with the outside world.  

Raspberry Pi Scratch Projects

 

Boat Race

  In this tutorial, you will help you learn how to design a competing game. Requirements
  • Software
Scratch 3, either offline or online
  • Hardware
A processor that can run Scratch 3  

Getting Started

  Begin by opening the starter project.  
Children Using Technology Devices

Children Using Technology Devices

 

How To Regulate the Boat

  Using the computer’s cursor, the player can now regulate the boat sprite. In addition, to enable the vessel to begin moving from the bottommost left part, and follow the cursor, compute code to the boat sprite.  

Testing the Code

  Once you test and see that the boat sprite is following the cursor directing up, your code is working.  

Rock Band

  Learn to make your musical instruments by coding.  

Requirements

 
  • Scratch 3 online or offline
  • Hardware
A processor that can run Scratch 3 You will need to add “sprites” to the base code before you start to code. Open a new Scratch project at http://rpf.io/scratch-new online. On the other hand, if you want to complete it offline, download it and install it on http://rpf.io/scratchoff. Search for drum sprite by scrolling down and then attach it to your project. From the list, choose the drum and drug it to the stage near the bottom. Additionally, add code blocks to it such that, by clicking, it will produce a sound. Try out the new instruments by clicking on the drum.  

Summary

  There is pretty much you can do with Raspberry Pi scratch. You can interact with it more physically when using it with Scratch Raspberry Pi extensions. Besides, it enables you to design codes hence the ability to regulate different modules thanks to its integration to Pi’s GPIO pins.