Category Archives: Scratch How-to

Connect a PicoBoard on Linux

PicoBoard Recently, I came across a forum post somewhere that mentioned the PicoBoard (formerly called a Scratch Board) worked in Linux. So, I set off to see just how easy it would be to get my PicoBoard working on Ubuntu 9.10.

Picoboards provide external sensors that feed input from the real-world into Scratch. The sensors are light, sound, resistance, button clicks, and slide control. And they’re a blast to use. I highly recommend them.

First stop, the PicoBoard driver download page. First the good news. There must be people requesting Linux drivers because the page supplies the ftdi_sio Serial to USB kernel driver as a download.

No Driver Download Required

The driver file on the download page is actually the FTDI USB Single Port Serial Converter. And if you visit the Sourceforge page for the project, you’ll find this advice from the previous project maintainer, Bill Ryder:

Use the most up to date linux kernel. This means 2.6.x or at least 2.4.30. The driver is included. I only ever use 2.6.x kernels so if you are using 2.4.x you are on your own. The driver is marked experimental at the moment. But I’m going to change that because it isn’t experimental any more.

Still, Scratch wasn’t detecting my PicoBoard. Though Linux was detecting the PicoBoard when I plugged it in the USB Port.

Load the Module

The ftdi_sio module is included with the kernel, but it wasn’t loaded for me. Here’s the command to load it:

sudo modprobe ftdi_sio

Now make sure the PicoBoard is plugged in and restart Scratch. The dmesg command is your friend here. It will give you feedback about how Linux is seeing the board. Here’s the last few lines of my dmesg output:

[451394.964027] usb 4-1: new full speed USB device using uhci_hcd and address 5
[451395.140265] usb 4-1: configuration #1 chosen from 1 choice
[451395.144909] pl2303 4-1:1.0: pl2303 converter detected
[451395.164947] usb 4-1: pl2303 converter now attached to ttyUSB0
[451470.917714] USB Serial support registered for FTDI USB Serial Device
[451470.917840] usbcore: registered new interface driver ftdi_sio
[451470.917843] ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver

The first four lines is the kernel detecting the device. Then remaining lines appeared when I loaded the ftdi_sio module.

A sample script

Here’s a quick script to test out the PicoBoard. Cameron is going to love this, especially when we combine it with the webcam support.

If you run into problems, I can’t say that I will have the answer, but I’ll definitely try. Feel free to ask for support.

Run Scratch from Flash Drives

Do you need to overcome security restrictions in your computer lab that prevent you from installing Scratch onto the workstations? Or maybe, you always want to ensure you have access to a working installation of Scratch.

Thankfully, Scratch will run on a usb flash drive and the Scratch download page provides a zip file that you can extract right onto the drive. You’ll need to look carefully for the link to the zip file. It’s buried in body copy.

Mac Users can install the dmg file to your flash drive.

Download the zip file and extract it to your flash drive. By default, you’ll extract the files to a Scratch folder on the flash drive.

To open Scratch go your USB drive , open the Scratch folder, and double click on the scratch.exe file.

Add Scratch to PortableApps

PortableApps.com provides a convenient way for users to run many popular open source applications, such as OpenOffice.Org and Firefox from a flash drive. The suite provides a menu of applications when you click on the PortableApps.com icon in the Windows System Tray.

While the applications available directly from http://www.PortableApps.com have their own installers, adding Scratch to the Portable Apps menu is as simple as moving the Scratch program files to the right folder on the flash drive.

The PortableApps suite creates a PortableApps folder on the root of the flash drive with all the applications listed in a subfolder of the PortableApps folder.
To make Scratch appear on the menu, extract the Scratch program files to the PortableApps folder; for example, E:\PortableApps\Scratch.

To make the PortableApps menu display the Scratch icon, open the PortableApps menu then select Options > Refresh App Icons.

That’s a quick little hack. Anyone up for creating a real portable app installer, which would optimize Scratch for the flash drive?

This information adapted and reposted from chapter 2 of Scratch 1.4 Beginner’s Guide.

Animated Dragon in Scratch

In Scratch programming, the broadcast block lets you coordinate events, so that one event triggers one or more new events. That’s a bit of an obtuse explanation. What’s an event?

Let’s make up a quick example and assume you call me on the phone.

Event: You dial my number.

Message: My phone rings .

Event: When I hear my phone ring, I pick up my phone and look at the caller ID .

Event: “Oh, I know that number,” I think. I answer the call.

Message: I say, “hello.”

And on it goes.

The following Scratch video shows you the broadcast concept using an animated, fire and ice breathing dragon.  When the author clicks the “Fire” button, the dragon breathes fire (an orange flame). Click the “Ice” button and the dragon breathes the blue flame.  Not much different conceptually than making a decision about which phone call to answer.

The code snippets in the video are not readable,  but it does a good job of demonstrating the broadcast concept. I’m personally more enthralled with the actual animation of the dragon, which is one of the primary reasons for sharing.

Recently, @Moodlegirl followed me on Twitter (@mike_b), and as I was looking through tweets,  I found this Scratch video.