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

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!
Richo

,

  1. #1 by Philippe Back on 17/Abr/2012

    Cool!

    I have to try this one out!

  2. #2 by Richi on 17/Abr/2012

    Please do. And let us know what you think :)

  3. #3 by Paul Wilke on 28/Sep/2012

    Great! many thanks, now I have something to play around :-)

  4. #4 by Job van der Zwan on 22/Jun/2014

    So I’m thinking of diving into Pharo, and my main usecase would be the type of code I would normally write up in Processing – interacting with Arduino sketchess is part of that.

    How does this compare to the newer physical etoys? I like what I’m seeing in the Pharo environment, but the etoys project seems more up to date. Any advice what I should do?

(No será publicado)


  1. No hay trackbacks