Controlling the Pi's GPIO with Scratch
Linux Format|November 2021
Les Pounder shows how we can use Scratch with simple electronics.
Les Pounder
Controlling the Pi's GPIO with Scratch

YOU NEED

  • Any Pi model
  • Latest Pi OS
  • 1x LED
  • 1x 220 Ohm resistor (RED RED BROWN GOLD)
  • 5x F2M jumpers
  • Breadboard
  • Push button
  • 1x PIR sensor
  • Get the code: https:// github.com/ lesp/LXF282ScratchGPIO-Basics/ archive/refs/ heads/main. zip

Scratch is meant for learning to code. It uses blocks to depict code and we can build sequences (algorithms) with relative ease. If something goes wrong we can take it apart and diagnose our code. As we’ve covered in previous issues, Scratch can also be used with the GPIO of a Raspberry Pi to learn electronics and in this tutorial we shall learn how to work with inputs such as buttons and a PIR sensor to control simple outputs such as LEDs.

Don’t let the simplicity of this fool you. Adding the PIR sensor to our robot project (LXF279) and tweaking the code will enable our robot to detect an obstacle, and then move around it. But before we can do that we need to know the basics, so here we go!

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; simply place a tick in the box and then click Apply to install. Once installed, Scratch 3 can be found in the main menu under Programming.

Denne historien er fra November 2021-utgaven av Linux Format.

Start din 7-dagers gratis prøveperiode på Magzter GOLD for å få tilgang til tusenvis av utvalgte premiumhistorier og 9000+ magasiner og aviser.

Denne historien er fra November 2021-utgaven av Linux Format.

Start din 7-dagers gratis prøveperiode på Magzter GOLD for å få tilgang til tusenvis av utvalgte premiumhistorier og 9000+ magasiner og aviser.

FLERE HISTORIER FRA LINUX FORMATSe alt
Create your first WebSocket service
Linux Format

Create your first WebSocket service

Mihalis Tsoukalos explains how to use the Go programming language to work with the WebSocket protocol.

time-read
9 mins  |
April 2023
Fantastic Mr Firefox
Linux Format

Fantastic Mr Firefox

Nick Peers takes a trip down memory lane to reveal the story behind the rise - and slight fall - of Mozilla's popular web browser.

time-read
9 mins  |
April 2023
Set up your terminal and email like it's 1983
Linux Format

Set up your terminal and email like it's 1983

Jump in the hot terminal time machine with Mats Tage Axelsson who emails from the command line using the latest technology.

time-read
8 mins  |
April 2023
Universal layer text effects with GIMP
Linux Format

Universal layer text effects with GIMP

Posters use them, films and presentations are hard to imagine without them: text effects. Attract attention with Karsten Günther and GIMP.

time-read
8 mins  |
April 2023
Jump to a federated social network
Linux Format

Jump to a federated social network

Nick Peers reveals how you can get up and running with this free, decentralised and non-profit alternative to Twitter.

time-read
9 mins  |
April 2023
Free our SOFTWARE!
Linux Format

Free our SOFTWARE!

Taking anything for granted is dangerous, so Jonni Bidwell and Mike Saunders revisit how the free software movement got started to help free us from proprietary tyranny!

time-read
4 mins  |
April 2023
Master RPI.GPIO
Linux Format

Master RPI.GPIO

Les Pounder goes back to the early days of the Raspberry Pi - and his career with this classic library! -

time-read
5 mins  |
April 2023
Waveshare Zero to Pi3
Linux Format

Waveshare Zero to Pi3

Transform your Pi Zero into a Pi 3, they promised Les Pounder, but it's more like adding on go-faster stripes.

time-read
2 mins  |
April 2023
The Best OPEN SOURCE Software Ever!
Linux Format

The Best OPEN SOURCE Software Ever!

In an attempt to trigger controversy, Michael Reed and Neil Mohr unequivocally state these are the greatest free software apps ever. Probably. We’re just trying to be helpful.

time-read
10+ mins  |
April 2023
Linux-Mandrake 7
Linux Format

Linux-Mandrake 7

Simplicity and a wide range of applications make this a great distribution for all Linux users.

time-read
2 mins  |
April 2023