Hardware Reference
In-Depth Information
Although this example is efective for introducing some important programming concepts,
it's hardly the best way the game could be coded. Scratch includes a message broadcast system
that allows code attached to one object to communicate with code attached to another,
which enables you to create much neater collision results that don't rely on carefully-timed
pauses in order to make sense.
To experiment with broadcasting, try using the broadcast and when I receive blocks
from the Control palette. A message created for a broadcast block in any object can trigger
code in any other object using the when I receive lag, meaning you can use it to link
multiple objects and their code together.
Robotics and Sensors
In addition to purely software-based inputs and outputs, it's also possible to tie Scratch into
external hardware using sensor boards and robotics systems. hanks to its multithreaded
nature and powerful inter-process messaging system, Scratch can be used to create a surpris-
ingly advanced robotics engine and is by far the easiest way to place a Raspberry Pi at the
heart of a simple robot.
Unlike Python, which is a more powerful but signiicantly more complex programming lan-
guage, Scratch can't make use of the Raspberry Pi's GPIO port to communicate with external
hardware. As a result, it needs some additional equipment before it can interact with the
physical world.
Sensing with the PicoBoard
Designed by the SparkFun electronics company, the PicoBoard is an add-on module that
connects to a computer running Scratch and provides a variable slider input, a light sensor, a
button, a sound sensor and four pairs of alligator clips that can be used to monitor external
electrical devices.
here are currently two types of PicoBoard: the original model, which uses a serial connec-
tion, and its replacement, which uses a USB connection. he latter is supported by the
Raspberry Pi. Simply connect it to a free USB port or a port on a USB hub connected to the
Pi, restart Scratch, and you'll be able to use its various functions within the Scratch interface.
Details on the PicoBoard can be found at http://www.sparkfun.com/products/
10311 .
Search WWH ::




Custom Search