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.
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.
- Start the graphical Desktop if you have not already by logging in and typing
- Start a terminal by double clicking the LXTerminal icon on the desktop.
- In a terminal type
sudo scratch to start Scratch with the necessary permissions.
- Hold down Shift key and click on the R in the Scratch logo.
- Click turn fill screen off.
- A white area at the bottom right side of the window will appear. Left click on the white area and select open…
- Click browser.
- The System Browser will appear. Click Scratch-UI-Panes
- Now click ScratchFrameMorph.
- Then click menu/button actions.
- Then click addServerCommandsTo:.
- Change the t2 ← true text in the code to t2 ← false.
- Hold the Control-Key and left click on the code. Click accept.
- In the box that appears, enter in your initials and click accept.
- Click the cross to close the System Browser.
- Shift-click the R again and select turn fill screen on.
- Shift-click the R again and select save image for end-user.
- If prompted about saving, click yes.
- To check that Mesh is now enabled, hold down Shift and click the Share menu. Check to see that Host Mesh option is available.
- Close Scratch.
- 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.