Information Obsolete Scratch Sensor now works with Scratch 2.0. The new info page is at https://emantpl.github.io/scratch-sensor-2.0

Scratch Sensor - the Android Smartphone as a DAQ module

Scratch is an interpreted dynamic visual programming language. Being dynamic, it lets code be changed even as programs are running. It has the goal of teaching programming concepts to kids and teens and letting them create games, videos, and music. It can be downloaded for free and is being used at home and in a wide variety of in-school and after-school settings around the world.

Connections between Scratch and other programs are made using the Scratch networking protocol. With this feature turned on, Scratch automatically sends all broadcasts and values of global variables out to any program connected to it. That program can also send broadcasts and global variables into Scratch. The Scratch Sensor is an Android app that uses the Scratch networking protocol to turn the Android Smartphone into a DAQ module and sends its accelerometer and compass sensor information and broadcast two states (jump and walk) to Scratch.

Getting Started

Please use Scratch version 1.4 only and familiarise yourself with the Scratch program before proceeding.
  1. Download Scratch Sensor from the Android Market.
  2. Download the example Scratch project.
  3. Note your Computer IP Address. Click the Start icon in the Windows taskbar. Paste cmd /k ipconfig into the search bar and press Enter. The screenshot shows the IP Address for the Wireless Network is 192.168.1.2.
  4. Load the example Scratch project. A Remote sensor connections enabled dialog should appear. Click OK. Click the green flag to Start.
  5. Start Scratch Sensor on your Android smartphone. If your smartphone wifi is not enabled, you need to enable it now. Enter your Computer IP Address that you obtained earlier. Press the Connect Button. You should see a Connected status.
  6. Hold the Android Smartphone in an upright position. When you rotate the phone, the direction value should change. The sprite faces only left and right due to the sprite setting (see Scratch programming).
  7. When the phone is moved up and down, the jump message is broadcast.
  8. When the phone is moved side to side, the walk message is broadcast.

Start from Scratch

  1. Start a new Scratch project. The following is intended for those familiar with Scratch and its programming environment.
  2. Get a sensor block and enable remote sensor connections
  3. Start the Scratch Sensor app on the Android Smartphone. Your wifi should be connected and the Computer IP Address should be correct. On the sensor block you can now select acceleration x, y and z values as well as direction.
  4. To receive the walk and jump broadcast message, place the Control->when I receive block. Enter either walk or jump.

FAQ

Q: I am getting a connection error.
A: Check the IP address. It may change when the router is powered down or reset. Also the Remote sensor connections in Scratch must be enabled before you click Connect in the Scratch Sensor App.

Q: Is the source code available?
A: Yes, it is available from github.com/emantpl/scratch-sensor