DigitalSandbox PicoBoard

Pages
Contributors: bri_huang
Favorited Favorite 1

Using Scratch

Scratch is an amazing platform for teaching an introduction to programming. It uses simple color-coded blocks that snap together to create programs or "scripts." It is designed with kids in mind, but the features and functionality of Scratch are extensive enough for you to create your own data-logging dashboards, arcade-style games, or full-length animations. Once you've uploaded the "Picoboard Arduino Code," the Digital Sandbox will work identically to the PicoBoard in Scratch.


Heads up! As of the writing of this tutorial, Scratch 3.0 and 2.0 does not fully support the PicoBoard. We suggest using Scratch 1.4 until the full PicoBoard extensions are implemented, tested, and rolled out with Scratch 2.0+.

To use the PicoBoard Sensor Blocks, click on the blue Sensing Palette:

alt text

At the very bottom of the list, there are two blocks that we can use. One is (slider sensor value) and the other one is a boolean/logic block < sensor button pressed ? > All of the sensors on the PicoBoard (Digital Sandbox) return a value from 0 to 100. It is a scaled value where 0 V ==> 0 and 5 V ==> 100 in the Scratch environment.

alt text

To help us get started, I like to just make a real quick and simple test script using just these four blocks:

alt text

Connect / assemble these blocks into a simple program like this:

alt text

Test it out!

Click the green flag and see what happens. The color of Scratch the cat should change as you move the slider back and forth. You should see the cat change from Orange --> Yellow --> Green --> Blue.

It seems like we're missing some of the colors. A little digging into the documentation on Scratch shows that the set color effect block operates on a scale of 0 - 200. So, to get the full range, we need to multiply the sensor value by 2. Grab a multiply block from the math operators:

alt text

Then, re-assemble the blocks so that it looks like this:

alt text

Click the green flag and try it again! How many colors does Scratch go through now?

alt text

Play around with other effect options and features. You can tie these to any of the sensors on the PicoBoard (Digital Sandbox) -- Slider, Light, or Sound. We tied the temperature to the Resistance-A sensor - which is also a range of values from 0 to 100.

alt text