1.Download ardublock-all.jar ArduBlock
2. In Arduino IDE, open menu “Arduino” -> “Preferences”
3. Find “Sketchbook location:”
- In Mac, it’s by default “Documents/Arduino” under user’s home directory
- In Linux, it’s by default “sketchbook” under user’s home director
- In Mac, /Users/abu/Documents/Arduino/tools/ArduBlockTool/tool/ardublock-all.jar
- In Linux, /home/abu/sketchbook/tools/ArduBlockTool/tool/ardublock-all.jar
- In Windows, C:\Users\abu\Documents\Arduino
5. Start the Arduino IDE and find ArduBlock under the Tool menu
Example of a ArduBlock Program
The drawers of ArduBlock are divided into 6 different categories.
Control
Control blocks are for program flow control
Numbers, Constants and Variables
These blocks provide access to computational data
Operators
These blocks provides operators for logical and mathematical computation
Utilities
These blocks provide access to utilities functions provided by Arduino platform
Bricks
These blocks provide more intuitive access to electronic bricks system.
Pin
This drawer probably needs a better name. The blocks here provide I/O access to Arduino Pins
Handling Digital Input and Output
The block below basically represent the “Hello World” of Arduino Programming mapping to the code fragments
if (digitalRead(1) == HIGH) { digitalWrite(2, HIGH); }
Multiple events on the same pin should be support by defining multiple events on the same pin. It seems that a good visual grouping of the same pin would be a good thing and improve readability of the program.
The OpenBlocks come with a pretty cool annotation system to add comments to block. This could be leveraged to enhance the readability of the program.
Handling Analog Input and Output
The analog I/O handling should work the same way as the digital one.
Doing conditional statements with Pin. The Pin 3 is identified with color in the ‘if’ statement. Maybe a label on it will work better.
Functional Programming or Object Oriented?
Since Clojure is used as programming language to drive the ArduBlock, it seems that it pushes my design of the block language to have more functional programming favor. It may be a good thing to make program more straight forward to understand and to program. But really need to guard against the tunnel vision.
Rule Engine?
Since I am using a rule engine in a project right now, I may also be influenced by that. I see all these blocks laying out conditions to trigger actions. It may be worth a while to see if a small Reta Algorithm can be easily implemented in Arduino to handle the rules layout by the blocks. This seems to be a nature way to design a run time for this language.
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:
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 openblocks on github. Appreciate any feedback on this.
source:
Aucun commentaire:
Enregistrer un commentaire