Blink Chip’s Eyes with ScratchGPIO (Preview)
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.
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.
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.
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.
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.
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.
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.
pin12on = 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.
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”.