User Menu

Blink Chip’s Eyes with ScratchGPIO (Preview)

This is a preview lesson. Please sign up for the course to access all lessons.

With the power off, connect Chip to the Raspberry PI using the Pi Pal Pi adapter. Chip should face forward and the Pi Pal Pi should be plugged into the row closest to the edge of the Raspberry Pi and start with pin number 2.

Pi Pal Pi side view Pixel Pi on Raspberry Pi

Chip on Raspberry Pi

 

Plug in your power to the Raspberry Pi and boot up.  Login to your Raspberry Pi. Start xwindows and you should have a ScratchGPIO icon on your desktop from when you installed ScratchGPIO. Click on the “ScratchGPIO 7” icon.

 

ScratchGPIO 7  Icon

 

Scratch will open up and you will receive a “Remote sensor connections enabled” dialog box. This means that Scratch has launched and is successfully communicating with ScratchGPIO. Essentially, ScratchGPIO is running as a Python script in the background listening for broadcast messages from Scratch. When it receives a message from Scratch it takes the appropriate action on the GPIO pins. When it receives signal/data/changes from the GPIO pins it passes it that the other way to Scratch.

Scratch GPIO Remote Sensor Connected

 

We are now ready to setup Scratch to talk to Chip and make his eyes blink. We will turn his eyes on, wait 1 second, then turn them off and repeat.

CHIP on RPI: Scratch Control

Drag over the Flag control and a broadcast box and click the down arrow to make a new broadcast message. Here is where we will setup Chip’s eyes.

Chip RPI: New Broadcast

 

You will receive a broadcast Message dialog pop-up window. In the dialog box type “pin12on” which tells ScratchGPIO to turn pin12 to the on, or High state. This is Chip’s right eye LED. Chip_RPI:Broadcast Dialog

Repeat this to create a broadcast message to turn his right eye off. We also need to repeat the process for his left eye. Take note of the broadcast messages in the screenshot below.

Chip_RPI: Scratch GPIO Blinkpin12on = right eye on
pin12off = right eye off
pin16on = left eye off
pin16off = left eye off

Click on the flag in the upper right hand of Scratch. Woo Hoo! You Did it! Chip blinked! Now lets make him blink several times. Before reading below, give it a try.

CHIP_RPI: Blink multiple times

Try this: make Chip blink his left eye when you press the letter “L” and blink his right eye when you press the letter “R”.

Chip_RPI- Left Eye Right Eye

 

 

Lesson tags: Chip, PixelPals, Raspberry Pi, Scratch, ScratchGPIO
Back to: Chip For Raspberry PI