I have been playing around with OpenBlocks. It’s a very flexible environment to create a new block language. When it comes to design one for Arduino, I found myself wondering between two different styles of design.
Design I
The first design is of course to follow the Arduino Language Reference closely. However, the resulting block language seems to be a bit too “verbose?” Or should I say “busy” since it’s really a graphical representation of the textual program. Here is a sample of what it looks like for the equivalence of codes here.
void setup() { pinMode(1, INPUT); pinMode(2, OUTPUT); } void loop() { if (digitalRead(1) == HIGH) { digitalWrite(2, LOW); } }
Design II
Since the block language is targeted at the beginner of Arduino and programming, most of time, we talk about “When the button on pin 1 is pushed, I want the LED on pin 2 to light up.” There is a much natural way to map this statement into an intuitive block language by building the blocks around the pin. Here is how it may look like:
![vpl-2.jpg Vpl 2](http://139.162.84.35/wp-content/uploads/2011/02/vpl-2.jpg)
This language is more concise and easier to understand. The language itself should provide enough meta info to infer the setup codes. However, in order to do this, the language may need a little runtime (OS?) to be compiled along with the Sketch but it seems to be worth the effort.
The OpenBlocks codes I am playing around with the idea is available at my ‘ant’ branch openblocks on github. Appreciate any feedback on this.
]]>