Pharo and Arduino
Posted by Richi in No clasificado on Febrero 22nd, 2012
Hi, if you happen to be a Pharo developer and a proud owner of an Arduino board, this might be of interest to you.
Given the recent mails related to Arduino in the Pharo mailing list, I decided to make a Metacello configuration to help the poor souls in need. So here it is, now you can load the Arduino project by evaluating the following:
Gofer it
squeaksource: 'MetacelloRepository';
package: 'ConfigurationOfArduino';
load.
(Smalltalk at: #ConfigurationOfArduino) load.
This will load two things:
- the Arduino-Core package, which contains a very simple model that lets you communicate with your Arduino via SerialPort using a firmware like Firmata (or a simple firmware made by us).
- the Arduino-Compiler package, a very rudimentary Smalltalk-to-C translator that lets you program your Arduino board without leaving Smalltalk. It’s pretty cool, but believe me, the translator is currently very limited, it doesn’t support any of the things that make Smalltalk fun. In fact, you’ll be writing ugly C code in a Smalltalk disguise.
Note that in order to upload your programs to the board, we need FFI to communicate with avr-gcc/avrdude. None of the Windows VMs I found on the Pharo website worked with FFI, I’m sure this will be fixed soon but for now I’m using a CogVM from Elliot’s website.
Also note that I prepared this only for Windows, making it work for other platforms would need some extra work. However, if you happen to be a Mac or Linux user, there is still hope: the Arduino-Core package will still work (I hope, it only needs the SerialPort working correctly), you’ll just have to upload the firmware manually (using the Arduino IDE for your platform) and, of course, you won’t be able to compile and upload programs from Pharo.
Once you install all the packages you’ll have to install several extra files the Arduino-Compiler package needs to work (the avr binaries, the arduino libraries, our firmware, and a couple more). Luckily for you, I’ve compiled them in a single file you can find here: http://www.mediafire.com/?1rep41uygl4rpf1.
Extract the contents of this file in the same directory where you have your Pharo image and now you’re ready to start playing. I suggest you try one of these examples I prepared:
Arduino ledExample. Arduino buttonExample. Arduino potentiometerExample.
I also encourage you to take a look at the Arduino class comment, it has some very useful code snippets.
Have fun!
Richo
















