A web-based alternative to Scratch

All Together Now

You can also use the script shown in Figure 18 to check that everything is working together. The script loops forever waiting for button presses on pin 24. The first time around, when a user presses the button, the script sets pin 17 (connected to your LED) to HIGH, thus switching it on. Then, it waits until the button is pressed again. When it is, it sets pin 17 to LOW, switching the LED to off. Then, the loop starts again.

Figure 18: The script waits forever for button presses.

From the users' perspective, it looks like you're using all the computing power of the Pi just to manage an on/off button (Figure 19) – which is true, but I'm sure you can come up with more exciting projects and expansions for the Snap! programming language, right?

Figure 19: Using all the computing power of the Pi to switch an LED on and off.

Buy this article as PDF

Express-Checkout as PDF

Pages: 9

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