Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By : Michael Badger
Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By: Michael Badger

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – revising the graph


As you see in the previous screenshot, the first point on the graph is moved to the right by 15 pixels. Our first measurement in the data that we graphed occurred at zero minutes is not accurately reflected in our graph. Let's make the graph match the numbers more closely by moving the circle sprite to the left for the first point as follows:

  1. Add a go to x: () y: () block before the repeat () block.

  2. Add the expression ((x position) – (15)) to the x value.

  3. Add the expression ((item (count) of (measurements) * (2)) to the y value. The following screenshot shows the revised script:

What just happened?

Our initial graph didn't properly mark the first point at zero minutes. In our revised script, we moved the circle sprite to the left by 15 pixels so that when we graph the first point in the repeat (length of (measurements)) block, the point was placed properly on the graph.

Have a go hero – brainstorming data collection topics

Unless you're monitoring a doorway that frequently opens and closes, recording the room temperature probably doesn't provide much excitement. Other items to measure might include a pot of boiling water or measuring how long it takes for a glass of ice water to reach room temperature.

You could also run a series of resistance tests with common materials. For example, attach the alligator clips to a potato, a paper clip, and so on. Record the values and then graph the results. You may need to modify the collection framework to record a value based on the occurrence of an event such as the button click on the PicoBoard or a key press on the keyboard.

Let's see what you can come up with!

Pop quiz – connecting to the real world

Q1. What Scratch block can provide an alternative to the PicoBoard's sound sensor?

  1. There is no alternative block.

  2. The play sound block.

  3. The loudness block.

  4. The microphone block.

Q2. Why would you choose to use Scratch 1.4?

  1. You want to use Scratch on the Raspberry Pi.

  2. You want to use the source code.

  3. Your current web browser does not support Flash.

  4. All of the above.

Q3. What do the analog ports on the PicoBoard measure?

  1. Sound.

  2. Resistance.

  3. Temperature.

  4. Weather.