Scratch your Arduino?

Why, yes you can. There are several projects I've played with that let you use the graphical Scratch-style programming to talk to your Arduino, which is excellent news for younger kids who are not ready for much typing or the "curly-bracket/semicolon" lifestyle just yet.

There are two different approaches to graphically programming an Arduino. The first is to run a sketch on the Arduino which talks to the Scratch program, passing commands and data over the serial port. The sketch is called Firmata, and requires the Arduino be attached to a computer running a server program to link Firmata with Scratch. Both Scratch for Arduino (S4A) and the newer Scratch to Arduino (S2A) use this approach. S2A seems a bit harder to set up initially, but works with the newer Scratch 2 Offline Editor.

The other approach is to translate the block structure into Arduino C-code for upload using the IDE. This might be a better option for older kids who are ready to make the transition from blocks because they can see the direct C-code equivalent. Both Blockly Arduino and ArduBlock projects take this approach, with ArduBlock actually integrating into the Arduino IDE making the transition from blocks to C-code at the press of a button. Blockly Arduino has the advantage of being web-based, so no installation is required, and the base project, Blockly, has some fun, non-Arduino, online programming tutorials.

I showed ArduBlock to one of the younger Teen Makers at the library program and he quickly programmed an LED to turn on or off at the push of a button. That may sound trivial on paper, but in practice, it is not. He had used Scratch before, and integrated some sophisticate techniques such as using flags to track state and a while loop to debounce the button.

Here is the equivalent C-code:

All of these tools make programming the Arduino a bit easier for younger programmers. They each have their strengths, but if you had to pick one, I'd go with ArduBlock because it is open source and integrates with the Arduino IDE. This makes it both easy to set up, and easy to use.


  1. Nice review, a new kind of visual programming tool called is coming soon.
    May be that will be a good choice for who want to make real projects.
    it is using flowcharts instead of "blocks"

  2. This is a great writeup and comparison of various approaches. For my students who want the full Scratch+Arduino experience, I’m recommending:
    o ScratchX if they have OS X or Windows systems, or
    o S4A on Fedora or Debian Linux boxes including the Raspberry Pi (ARM version for the RPi)

    If you want to write standalone code for the Arduino (not connecting through Firmata or S4A firmware, then):
    o ArduBlocks for OS X, Windows, and most Linux systems (but not Raspberry Pi).

    Regarding ArduBlocks, though the code is pure Java and should be 100% portable, weird things happen when you attempt to run it on a Raspberry Pi (plus it’s horribly slow), so I don’t recommend it. I’ve had no issues with it on other systems, and the blocks are quite powerful. Look for the latest ‘beta’ version (currently “ardublock-beta-20140828.jar” ) which is available on SourceForge and not the main ArduBlock website (link below).

    The Arduino extension for ScratchX is quite powerful and able to access all of the pins even on large Arduino boards like the Mega 2560 or Due (which is fairly rare). It may take a bit of effort to get the plug-ins fully installed and security settings enabled so they’ll run under OS X or Windows. I’ve had success getting it working under OS X El Capitan using Safari, but Firefox works much better. Won’t work in Chrome at all, from what I can see (due to lack of NPAPI plug-in support).

    We’re starting to share files back and forth on the µCauliflower Brew Club on Facebook — come join in if you’d like (open to all).