Graphical, Scratch-like programming languages for Arduino

Lead Image © Dietmar Hoepf,

Arduino Bricks

Getting a handle on Arduino boards can be difficult. Luckily, quite a few block-based, Scratch-like programming environments are at hand that make the learning curve easier to climb.

Programming the Arduino using Processing, a C-like language, is tough. C is unforgiving and can be arcane, which makes it difficult to teach to beginners and kids. Fortunately, several graphical programming languages, similar to Squeak or Scratch, can help you learn the basics of the Processing language.

Even before the Raspberry Pi (Rasp Pi)was a twinkle in Eben Upton's eye, Arduino was already being used in education, albeit originally for higher education and professionals. As Arduino became more and more popular, it was unavoidable that someone, somewhere would come up with the idea of using it with younger students. To further this goal, several Squeak/Scratch-like projects popped up over the years that can help newbies and younger kids get their heads around programming for the Arduino. I'll discuss a few of them.


BlocklyDuino [1] is based on Google's Blockly library [2] project, which allows developers to create graphical block-based front ends for any language or, in this case, device. For example, the Rasp Pi has a Blockly implementation [3].

To get started, either grab the code for BlocklyDuino from the GitHub website or use git to clone the repository:

git clone

BlocklyDuino works by connecting to a Python web server that serves as the front end to a web browser and then uses tools from the Arduino IDE to compile and upload your programs. That means you have to have a working version of the official Arduino IDE installed for BlocklyDuino to work.

In theory, when you run the Python web server, it should be able to detect the port your board is connected to, but that didn't work for me. You can specify the port by hand, though: Plug your board into your computer and, in Raspbian and other Linuxes, look at the output from:

ls /dev/tty*

Your board will normally appear connected to the /dev/ttyACM0 or /dev/ttyACM1 port, or something like that. Now pass the port onto the server when you run it:

python --port=/dev/ttyACM0

The output will inform you that the server is running on Open a web browser and visit that address, and you will see the BlocklyDuino web interface (Figure 1).

If you have ever used Scratch, the interface should immediately be familiar: Use the menu on the left to choose a category and drag and drop blocks onto the workspace. You can then click them together like Lego bricks to build programs. In the example shown in Figure 1, you can see the classic "Blink" script.

Figure 1: BlocklyDuino includes special blocks that allow you to program for the Grove range of add-ons.

Clicking the Upload button at the top of the workspace uploads the sketch to the board. You can also see what the code would look like translated into Arduino's native Processing language. Click on the Arduino tab at the top of the workspace, and you'll see something like the code in Figure 2. You can't actually modify anything in this screen, so it is more useful as a learning aid than anything else. I suppose you also could use it to copy and paste code from BlocklyDuino to the Arduino IDE if you are having trouble uploading via the Python web server.

Figure 2: Use the Arduino tab to see what your code would look like in Processing.

Internally, BlocklyDuino uses an XML file to store the "code," so if you want to save your work and later continue, you should use the Save XML and Load XML buttons. You can also export your work to an Arduino-compatible file, but that is only useful if you want to continue working on it in the Arduino IDE, because you can't go the other way round (i.e., from Arduino code to BlocklyDuino).

Although you can't import customized libraries into BlocklyDuino, it does come with some built-in goodies. If you drag out one of the blocks under Servo, for example, BlocklyDuino will automatically import the Servo.h library. BlocklyDuino also includes blocks for many of the Grove Arduino add-ons, including actuators (buttons, buzzers, joysticks, etc.) and sensors that can easily be connected to Arduino. Because beginners and kids learning to use Arduino use the Grove add-ons, it makes sense to support them.

Does it work on the Raspberry Pi, though? Yes. The server is pretty lightweight, so it doesn't bog the Rasp Pi 3 (RPi3) down too much. You will have to install Firefox ESR (sudo apt-get install firefox-esr) to get all the JavaScript bits working. Having had bad experiences with JavaScript-heavy web apps in the past, I thought that BlocklyDuino might tie up the Pi, but no: Everything worked very smoothly.


Another Blockly Arduino language, Ardublockly [4], is quite similar to BlocklyDuino, which is not surprising because it is a fork of latter. However, it does have some distinguishing features that make it worth looking at.

To begin, grab the latest code from the project's GitHub repository, change into the ardublockly/ directory, and initialize some submodules:

git clone
cd ardublockly
git submodule update --init --recursive

As with BlocklyDuino, you start a server/application from the main directory:


Although BlocklyDuino requires you to navigate to a web page, Ardublockly opens a browser window for you (Figure 3) – or a new tab if you already have your default browser open. If that fails, you can point your browser to http://localhost:8000/ardublockly/.

Figure 3: Ardublockly includes blocks that allow you to write to and read from the serial channel.

Once you have the interface up on your browser, the first thing you should do is configure it for your board. Click on the three-line menu icon in the upper left corner and select Settings. Here you will be able to tell Ardublockly where it can find your Arduino executable (yes, as with BlocklyDuino, ArduBlockly needs the standard Arduino IDE files to compile and upload your programs), the type of board you are using, the port it is connected to, and so on (Figure 4). Be warned that the interface worked only so-so in Firefox. It worked much better in Chromium and Chrome.

Figure 4: Be sure to configure your board; otherwise, you won't be able to upload your programs.

Use the buttons in the upper right corner of the workspace to check and upload your program. You also have the option of opening your sketch in the Arduino IDE.

Ardublockly does not include Grove System blocks, but it does have more general-purpose blocks, including ones that allow you to monitor, read from, and write to the serial channel (useful for debugging). However, Ardublockly doesn't seem to have its own serial monitor, so you will have to use the button mentioned above to open your program in the official Arduino IDE and use the monitor that comes with that (Figure 5).

Figure 5: Ardublockly doesn't have its own serial monitor, but it can show output from the Arduino IDE.

Another nice touch is that Ardublockly comes with a fold-down panel at the bottom of the screen that can show you the output from the Arduino IDE. This is useful if, for example, you are having trouble uploading a sketch or it isn't working as it should.

Does it work on the Rasp Pi? Kinda. The server doesn't seem to bog down an RPi3 much, but as with Blocklyduino, you will have to install Firefox ESR to get all the JavaScript goodness to work. Even on Firefox, though, I had problems with some of the interface's elements misbehaving or not showing up at all.

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content