Scratch visual programming

Scratch is a very easy to use and learn language designed by the MIT Media Lab mainly intended to introduce programming to children aged 7-16. I can be fun to older people as well. Scratch is a visual programming language. It can be accessed as a free desktop and online multimedia authoring tool that can be used by students, scholars, teachers, and parents to easily create games and provide a stepping stone to the more advanced world of computer programming.

Getting started with the Scratch is easiest if you have web browser that support Flash: Just go to Scratch web site at Viewing the existing projects available on the Scratch website, or modifying and testing any modification without saving it requires no online registration.  Scratch allows users to use event driven programming with multiple active objects called “sprites” (either vector or bitmap graphics). You can use Scratch for example to make animated stories, and interactive art, music and games (technology is used in the game creation tool Stencyl). You can test how the examples work, look how they are built and even change how they work – all in your web browser and in many languages. The idea is that you can create stories, games, and animations to share with others around the world (and they can make their own adaptation of them).




Some examples:

Pong Starter is a good starting point to get into the idea how Scratch works:


DJ Scratch is a simple project that mixes sounds based on the keys you press on your keyboard.


If you are into making games, check out The Ninja 2 game project. Just make few changes (like your own player character) and you have a full game to play…



Technology behind Scratch on browser

Scratch in the web uses Flash technology for presenting the interactive content. Why Flash editor over HTML5? Currently used Scratch 2.0 is a completely flash-based program, in which both the project editor and project page viewer use the same player, the Flash player. While I don’t like Flash too much, I think it is better than Java Player used in earlier version.

HTML5 support may be coming some day.  The HTML5 Player is an upcoming project viewer that will allow projects to be run on any device that executes HTML5 code. This will allow for projects to be viewed on tablets, smart phones, and most internet devices, because multiple devices support HTML5 unlike Flash. The code for the HTML5 player has been posted on GitHub here. The project is far from complete and needs for example PHP proxy between another domain and Scratch


Interfacing hardware and other software to Scatch

The simplest way to connect some external hardware (like for example sensors and controls) to your Scratch app is to use hardware that emulates keyboard and mouse operation. I have for example earlier  tested Makey Makey invention kit: The computer just thinks MaKey MaKey is a regular keyboard. It sends key codes to computer when you use your own touchpad keys. MaKey MaKey can also emulate a mouse. This method works on web and desktop versions.

Sometimes just creating just interactive multimedia that runs on browser is not enough – maybe you need to control some hardware from your Scratch application. In that case you need to install free desktop editor. Using Scratch 2.0 Offline Editor you get some new tricks that you can do with Scratch: Interacts with hardware and other software running in the computer. Scratch 2.0 cannot interact with hardware devices directly, but with hardware extensions that come with a helper app it is possible to make Scratch applications to talk hardware devices and other software.

With Experimental Extensions, you can create Scratch projects that connect with external hardware (such as electronic devices and robotics) and online resources (including web data and web services).

At the moment Scratch communicates with the helper app via HTTP requests, and the helper app talks to the hardware. In the future, some extensions may package their helper apps as browser plugins.

The Remote Sensors Protocol or Scratch Extension Protocol is an experimental extension feature that allows interaction between Scratch and other programs. Messages are sent in both directions over the socket connection (Scratch listens for connections on TCP port 42001).  A sensor update message includes one or more (variable name, value) pairs.

It is also possible to construct a UDP packet from scratch and inject it on a WiFi interface in Linux.

Interfacing Scratch to Arduino

There are lots of people who are very comfortable with the Scratch programming environment but want to try something with Arduino to Blink Lights, Sense Buttons, Run Servos or whatever.

An Arduino extension is available on ScratchX, a Scratch sister site hosting experimental extensions. See the instructions for the experimental Arduino extension for Scratch.

S4A is a Scratch modification that allows for simple programming of the Arduino open source hardware platform. It provides new blocks for managing sensors and actuators connected to Arduino. In S4A, an Arduino board is represented by a special kind of sprite. S4A works with Arduino Diecimila, Duemilanove and Uno. S4A interacts with Arduino by sending the actuator states and receiving sensor states every 75 ms. S4A requires you to install software both in your PC and your Arduino board. S4A allows for 6 analog inputs (analog pins), 2 digital inputs (digital pins 2 and 3), 3 analog outputs (digital pins 5, 6 and 9), 3 digital outputs (pins 10, 11 and 13) and 4 special outputs to connect Parallax continuous rotation servomotors (digital pins 4, 7, 8 and 12). Using Scratch Programs you can make Arduino Flash Lights, Read Buttons, and do many of the things that you can do with the the regular Arduino environment.

Using Scratch as SCADA interface

Simple SCADA using Scratch and OSHW article shows how to build Simple Supervisory Control and Data Acquisition (SCADA) using Scratch and some open source hardware boards connected to a GNU/Linux Ubuntu computer using USB. With a Scratch that has remote remote sensor connections enabled you can connect to an interface software that handles the communications with your USB hardware that does the actual controlling.


  1. Tomi Engdahl says:

    What if you want to program games with Python?


    Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language. It is built over the Simple DirectMedia Layer (SDL) library

    This is based on the assumption that the most expensive functions inside games (mainly the graphics part) can be abstracted from the game logic, making it possible to use a high-level programming language, such as Python, to structure the game.

    Pygame applications can run on Android phones and tablets with the use of Pygame Subset for Android (pgs4a).

  2. Sooraj Krishna says:

    I was trying to connect Scatch with wekinator ( A machine learning tool for artists) through OSC messages using OSCBrigdge for Scratch. But i am not able to enable the remote sensor connection to connect the Scratch with OSCBridge. Can you give some help ?

  3. Tomi Engdahl says:

    Steven Levy / Backchannel:
    Behind the 10-year evolution of Scratch, a programming language from MIT Media Lab, which has introduced coding and collaboration to millions of kids — At 10, Scratch is a popular tool to teach kids programming. But its real glory is how it imparts lessons in sharing, logic, and hackerism.

    This Computer Language Is Feeding Hacker Values into Young Minds

    At 10, Scratch is a popular tool to teach kids programming. But its real glory is how it imparts lessons in sharing, logic, and hackerism.


Leave a Comment

Your email address will not be published. Required fields are marked *