Tag Archives: Raspberry Pi Geek

Articles and Scratch projects that appeared in Raspberry Pi Geek Magazine.

Building a Motion Detector using Scratch GPIO server

gpio-server-scriptAs of the Raspbian Jessie release, Scratch provides easy access to the Raspberry Pi’s GPIO pins. This project incorporates the new GPIO server to build a motion detector.

The release of Raspbian “Jessie” introduces a new version of Scratch (September 2015) that enables access to the Pi GPIO (general purpose input/output) pins by default. I’ll demonstrate the new built-in features by creating a motion detector so you can sense when something or someone moves; it’s perfect for keeping tabs on your bedroom or the cookie jar, or catching your dog eating off the counter when you’re not home. In addition to an updated version of Scratch, you will need two LEDs, resistors, a passive infrared (PIR) sensor, and your breadboard to build a motion detector.

Accessing the Pi’s GPIO pins from within Scratch has been possible for several years, but it previously required a separate installation of Scratch called ScratchGPIO, which I’ve used in previous Raspberry Pi articles, from Simon Walters (aka cymplecy). The Scratch GPIO server now enables access from the default installation of Scratch. In addition to the GPIO pins, you gain access to several other commands to get the time, IP address, and photos from the camera module.

The Scratch GPIO server – like the ScratchGPIO and Mesh features I’ve covered in previous Raspberry Pi Geek articles – rely on broadcast messages to communicate outside of the Scratch interface. This puts a special emphasis on using carefully constructed commands (syntax) to make Scratch do what you expect. In a Scratch programming environment, the focus on syntax creates a more advanced deviation from the drag-and-drop interface that makes Scratch so easy to understand.

Using the Scratch Paint Editor to Draw and Animate a Hungry Cat Racer

hungry-cat-racerUsing Scratch’s built-in graphics editor is a perfect way to introduce Scratch to novice programmers of any age. Experienced Scratchers can create detailed animations that enhance any project. In the Hungry Cat Racer game, I’ll show you how to draw multiple backgrounds and edit sprite costumes that will become the basis of the game’s animated effects.

When I introduce Scratch to young programmers, the built-in graphics editor is often a perfect place to start; students can take an existing project and immediately customize it without any initial programming while still engaging in something creative. When customizing projects, the students invariably start drawing their own characters, and then, of course, they want to program those characters to do something.

The setup for this project will involve the Paint Editor, and although I won’t go over each option in a tool-by-tool review, I will show you the possibilities. In other words, a five-year-old can hack together a ninja character (that might look like blue spaghetti to you) or a more practiced artist can draw polished images. But for painting your house, you can consult affordable timber deck restoration in Brisbane like Super paint Residential and Commercial painting service. You can get the best professionals for painting and cleaning your painted wall here. You can also contact expert painting contractors from a professional painting service like Euro painting for reliable painting services. Check out their service page to learn about all their services.

Host a secret chat using Mesh

mesh-chatScratch has a secret feature called Mesh that enables multiple projects to interact with one another via broadcasts and variables. To demonstrate the feature, I’ll show you how to create a simple chat program.

Note: This is not a suitable Scratch 2.0 project, where chat clients are prohibited. But this project is 1.4 based and uses the mesh feature which is designed to work over a local network.