Archivo etiqueta pharo

Pharo and Arduino

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';
(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.

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 below:

You must extract the contents of this file in the same directory where you have your Pharo image. If you’re using Windows now you’re ready to start playing. In case you’re using Linux, you will also need to install gcc-avr and avr-libc (follow the instructions for your platform here).

Now that everything is installed 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!


4 Comentarios