Scratch, Python and Google Apps Script

At today’s Manchester CoderDojo at The Sharp Project, we embarked upon our three-month (three-meetup) project to try and build the “World’s Largest CoderDojo Rube Goldberg Machine”.

This is a machine that is part-physical, part-virtual, and is all about connecting up real and online things to build a chain of events that span the physical and virtual, different ages and skill sets, various hardware and software platforms … a chain of events that will do, well, we’re not sure yet, except that it will be a lot of fun.

We started experimenting today with Python and Scratch. Scratch enables remote connections via port 42001 and we wrote a simple Python script to connect to that port and listen out for broadcast messages from Scratch. That was fairly straightforward, and we even managed to send broadcast messages to Scratch as well as receive them from Scratch.

So we decided to go a step further. Why not connect to the interwebs and place some data somewhere? A good platform for experimentation is Google Apps Script, which is a JavaScript-based glue language running on a platform, with myriad library services, that makes it very easy to manipulate Google Drive content – for example, spreadsheets – and tons of other stuff too.

With this goal in mind, we extended the Python script to send some data to a Google Apps Script, which we set up to act as a published web service (platform-as-a-service FTW!), which in turn wrote data to a Google spreadsheet. No particular reason, but why not? And not only were the results immediately visible, but also in a place that encouraged further linking and triggering.

I recorded a short screencast of all of this in action, showing just a few of the connectivity building blocks we’ll need to build our Rube Goldberg machine.

The screencast is here:

Interested in helping out? Come along to next month’s CoderDojo!