Scratch with PiFace Digital

Difficulty: beginner

How to setup and use Scratch with PiFace Digital.

Setting Up Scratch to use PiFace Digital

Scratch is a great graphical way of programming and can be set up so that it can read the inputs and control the outputs of PiFace Digital.

This page contains the steps which must be followed to allow Scratch to talk to PiFace Digital.

PiFace connects to Scratch through a mechanism called Mesh. Mesh is not enabled by default in Scratch so you either need to download a version of Scratch that it is enabled in, or enabled it yourself. The following steps show you how to enable Mesh yourself. They are based on the steps detailed here: http://wiki.scratch.mit.edu/wiki/Mesh

Note: These steps to enable Mesh need only to be done once, and are not needed each time you run Scratch.

Before Starting!

Check: Before following these steps you should have set up your Raspberry Pi so that you can run the PiFace emulator and the Scratch handler.

Enable Mesh

To use PiFace Digital with Scratch first we need to enable Mesh functionality. This only needs to be done once. However, because it makes changes to Scratch itself, we need to use sudo. Once the changes have been made, you should not use sudo with Scratch.

  1. Start the graphical Desktop if you have not already by logging in and typing startx.
  2. Start a terminal by double clicking the LXTerminal icon on the desktop.
  3. In a terminal type sudo scratch to start Scratch with the necessary permissions.
  4. Hold down Shift key and click on the R in the Scratch logo.
  5. Click turn fill screen off.
  6. A white area at the bottom right side of the window will appear. Left click on the white area and select open…
  7. Click browser.

  8. The System Browser will appear. Click Scratch-UI-Panes
  9. Now click ScratchFrameMorph.
  10. Then click menu/button actions.
  11. Then click addServerCommandsTo:.
  12. Change the t2 ← true text in the code to t2 ← false.
  13. Hold the Control-Key and left click on the code. Click accept.

  14. In the box that appears, enter in your initials and click accept.
  15. Click the cross to close the System Browser.
  16. Shift-click the R again and select turn fill screen on.
  17. Shift-click the R again and select save image for end-user.
  18. If prompted about saving, click yes.
  19. To check that Mesh is now enabled, hold down Shift and click the Share menu. Check to see that Host Mesh option is available.
  20. Close Scratch.
  21. Start Scratch with normal permissions, that is by typing scratch (no sudo required)

    or by double-clicking the desktop icon. Shift-click the Share and check the Host Mesh option is still available.

Scratch is now enabled to talk to other devices through Mesh.