Installing Your Scratch Board

Installing a Scratch Board on your computer is a relatively quick and easy process and begins with downloading the software driver. Two different types of software driver downloads are available, one for Microsoft Windows and one for Mac OS X. To download the drivers for your computer, go to http://scratch.mit.edu/pages/scratchboardsetup and click on one of the following links (Windows Vista users can skip this step because your computer should automatically install the needed software driver):

  • Windows XP (and older) Driver

  • Mac OS X Driver

Once you have downloaded the appropriate software driver for your computer, you need to install it. On Microsoft Windows this means extracting the installation program from the Zip file, double-clicking on it, and then following the instructions that are provided.

For Mac OS X users, installing Scratch’s software drivers involves opening the file that is downloaded and then double-clicking on the .dmg file that is stored inside. This displays a .pkg program, which when double-clicked executes the driver installation process. Click on Continue to begin the installation process and then follow the instructions that are presented.

Once you have installed the software driver on your computer, connect the USB portion of the cable that came with your Scratch Board to your computer’s USB port and then connect the serial portion of the cable to your Scratch Board. At this point your Scratch Board should be ready to use.

Using the Sensor Block to Interact with Your Scratch Board

In order to programmatically interact with a Scratch Board, you need to work with the two sensing code blocks shown in Figure 14.2.

Figure 14.2. Access to a Scratch Board is provided through these two sensing code blocks.


The first code block shown in Figure 14.2 returns a range of data, from 1 to 100, for the selected Scratch Board sensor. In addition, you can select this code block’s check box to enable the display of a monitor on the stage, allowing you to keep track of the data that the sensor is returning. This code block works with the slider, light, sound, and all four of the resistance controls (alligator clips).

The second code block shown in Figure 14.2 returns a value of true or false, depending on whether the Scratch Board’s button control has been pressed or one of the resistance controls has been used to establish an electrical connection (the alligator clips are connected to one another).

Examples of how to work with both of these sensing code blocks to receive data collected by each of the Scratch Board’s sensors and controls are provided throughout the rest of this book.

Collecting Input Using the Slider Control

In order to work with the Scratch Board’s slider control, you must use the first sensing code block shown in Figure 14.2. This means dragging and dropping an instance of the code block into another control, where it can be used to provide input; then select Slider from the list of choices displayed in the control’s drop-down list.

As an example of how to work with the control, let’s create a new Scratch application that emulates a virtual fan. To do this, you will create a new application and then import the sprite shown in Figure 14.3 into it. You will find a copy of this spite on the book’s companion CD-ROM. You will also need to remove the default Cat sprite.

Figure 14.3. The speed at which the fan spins will be controlled by the Scratch Board’s slider control.


Once added to your application, select the sprite and then add the following script to it. As you can see, this script places the sprite representing a fan in the middle of the stage and then uses a loop to retrieve a continuous feed of data from the Scratch Board’s slider control. Using this data collected from the Scratch Board as input, a motion block is used to rotate the sprite.

The sprite has been set up so that its rotational center is directly in the center of the black circle in the middle of the sprite. Moving the slider by a small amount will make the fan begin to slowly spin. Moving the slider control by a larger amount will increase the speed at which the fan spins. Using a similar approach, you can use a Scratch Board as an input device for all kinds of Scratch applications. For example, you might use it as a means of controlling a paddle in a Breakout-style game or to control the assignment of data to a variable, which in turn is used to control an application’s operation. The possibilities are endless.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.102.112