Skip to content

amandaghassaei/ScratchSerialExtension

Repository files navigation

ScratchSerialExtension

This is a Serial Communication extension for Scratch - it allows you to pass serial messages between the scratch interface and any serial device.

To run the extension, go to:

scratchx.org

Download this repo, then go to File>>Load Project in Scratch and open the file called SerialDemo.sb2. Many blocks will initially load up red and undefined, that's ok.

Click "Load Experimental Extension", and paste in the following link:

http://cdn.rawgit.com/amandaghassaei/ScratchSerialExtension/281d2f3fd45102a65fc798b03bb920b07c693211/serial_port_extension.js

Serial communication happens through a node.js server that must be running concurrently with scratch. To use the node server, first install nodejs:

node.js

this will also install the node package manager (npm), use npm into install the following dependencies from the terminal:

serialport
npm install -g serialport

socket-io
npm install -g socket.io

Navigate to the parent directory of this repo in the terminal and run:

node nodeServer.js

to start the node server.

If you want to know more about how node.js, socket.io, and serialport allows your browser to communicate with serial devices, check out a simple demo of standalone node server with web client I wrote here.

I used documentation from the Lifelong Kindergarten Group to set up the Scratch interface for this extension. I'm working on a version of this extension that uses Scratch's serial browser plugin, but am still trying to get that up and running. The latest version of that code is in the branch "serialplugin".

I've included a sample Arduino sketch in this repo that listens for incoming serial messages and repeats them to test this Scratch extension.



Attribution:

Door sound effects from freesoundeffects.com
Bike Horn sound effect from soundbible.com
Swoosh sound effect from soundbible.com