SCRATCH
Building robots inScratch with GPIO
Take your first motorised step with Les Pounder as he shows you how to use Scratch to build and control a simple robot.
OUR EXPERT
Les Pounder is associate editor at Tom’s Hardware and a freelance maker for hire. He blogs about his projects and adventures at bigl.es
Robots are very cool and the Raspberry Pi GPIO is the ideal way to control them. We can do this using Scratch. In this tutorial we shall learn the basics of working with the GPIO in Scratch by first controlling an LED before applying the same principle to control the motors of a robot. If you’re unsure as to how to build a robot, we have a short guide in the boxout which may just help. So let’s build a robot!
Scratch 3 should come pre-installed on your Raspberry Pi OS image, but just in case it’s missing it can be installed from the main menu, under Preferences>Recommended Software. Scratch 3 is found in the Programming category; place a tick in the box and click Apply to install. Once installed, Scratch 3 can be found in the main menu under Programming.
Open Scratch 3 (on first start Scratch may take a little while to open). We’re going to assume that you have an understanding of how to code with Scratch, (if not see LXF180/1, 207, 209, 277/8). Before we write any new code we need to click the blue folder icon in the bottom left of the screen to load the Extensions menu. From there select Raspberry Pi GPIO and a palette of new blocks is added to our code.