Thursday, July 25, 2013

Of videogames, arduinos and 10 year olds


That's Mr. Visual Python to you (the visual module, that is). At the last PYPTUG meeting, Aaron Titus gave a talk on Visual Python. I think it was about writing (well, mostly playing) videogames under the veneer of learning physics. :)

All joking aside, it was a really great talk. It was also the first time we were using Google+ Hangout to help some members to check the presentation. And particularly a father and daughter who would not have been able to make it in time for the meeting. More on that further down.

Pyfirmata lightning talk

So I gave a lightning talk on Pyfirmata and Arduinos. It was part of my talk at PyCarolinas last year but didn't have time to go into the code detail (plus another talk earlier that day had covered really extensively serial communications). And it's really about serial communications (be it USB, bluetooth or plain old RS-232/rs-422) and microcontrollers (it's not just for the 'duinos). I ran the python code on a Raspberry Pi, but you could use pretty much any computer that can run python.

The protocol is firmata:

The python module is Pyfirmata:

To install, you can use :
pip install pyfirmata
easy_install pyfirmata

Since both pip and easy_install automatically install dependencies, that's all there is on the host computer side.

Or from source using, but you will have to install the serial module.

You dont have to handle the serial stuff yourself, just point to the right /dev/ (serial, usb or bluetooth), start an interator and start using read(). Pyfirmata handles the serial itself and sending/receiving the sysex bytes (Firmata is a MIDI inspired protocol).

To install the firmata firmware on the Arduino, start the IDE and go to:

The bitbucket repository for my talk (presentation and simple example that reads values from analog port 0 on the arduino) is at:


The young coder

"After watching the stream, this morning I left my 10 year old building spheres and boxes in VIdle.  She'd never done programming of any kind before last night." -- Ryan

I think this speaks volume about Python and the visual module. And that's what PYPTUG is all about. Now we just got to get her a Raspberry Pi.


No comments: