Building a Motion Detector using Scratch GPIO server

Lead Image © kudryashka, 123RF.com

In Motion

As 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.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Stop-motion animation

    Stop-motion animation doesn't require expensive cameras and movie editing software. With Scratch and a Pi camera, you can become your own director, producer, and publisher.

  • Creating a multiplayer quick-reaction game

    The quick-reaction game provides an introduction to building simple circuits with the Raspberry Pi and controlling those circuits with ScratchGPIO, an advanced version of Scratch.

  • Diving Deep

    The past year has seen a continued emphasis on STEM (science, technology, engineering, and mathematics) education in English-speaking countries.

  • PHP on Raspberry Pi

    Getting started with PHP on Raspberry Pi is easy. We show how to build a simple PHP app to control an LED.

  • Building a video-enabled nest box

    We show you how to build a completely wired nest box that charts the movements of nesting birds and delivers photo images of hatchlings.