Arduino, Midi driven Leds/Stuff

Here are a few step to set-up the basis for an interactive installation with lights(or solenoids, or whatever you can imagine) driven via midi commands, an easy way to planning what has to light up and what has to shut down via a midi track, like this sample image show(a note in time sets light up or shut them off).
Image

I’m using Serial <> MIDI converter from spikenzielabs.
All the stuff, inner working, files, installation and usage steps are explained here http://www.spikenzielabs.com/SpikenzieLabs/Serial_MIDI.html

Basically you need to create two midi ports via you’re preferred audio configuration system in your preferred operative system, and the map them to be used in your serial midi tool.
The serial midi tool acts like a proxy, if you want to put it in this way.
Here is a drawing to explain a little bit the underlying architecture.(made with balsamiq mockups webdemo -> code http://pastebin.com/nY2tAUAK )


You need Processing to run the converter program(script), but you can create the application once for all with processing itself.
The example in the site linked above does only a write on the serial port, and it makes arduino send midi to the computer.
I’ve done it the other way, my computer sends midi to the arduino and the arduino acts accordingly to what I’ve told him to do.

Steps to follow:

  1. connect arduino and if you haven’t already done it, upload sketch(once you’ve done it, you’re ok with arduino)
  2. start serial <> midi (select midi ports you’ve previously created)
  3. start midi software(and if you haven’t configured it yet, do it)

All this happens via software, no hardware needer other than an arduino board with some resistors and Leds.
There are many guides out there that open apart a midi connector and plug it in the arduino to make an arduino talk directly to midi devices, but this is not the case.

Here is the arduino code (sketch) that I’ve put up (with some help of internet)
http://pastebin.com/e8ekuyTE 

Here is a screenshot of my desktop during the process

Here is a (bad quality)video of me sending midi notes to the board.

Quickly process a JSON string

So this method is so naive that I’m not so proud of it.
But “hey, we have plenty of resources now, and we I’ve paid for it!” they say…
Actually this a homemade/handmade/whatever kind of parser for a JSON string like this:

{“user”:”paraimpu”,”text”:”Hi Twitter buddies”, “created_at”:”Wed, 05 Oct 2011 13:45:03 +0000″}

What I do: I analyze every character of the json string, and look for a first  quotation mark like this ” .
Then I save all of the text until I find another quotation mark.
All the rest is ignored.
I build a string with all the characters inside the two quotation marks, and then add that string to a List.
Then I scan that list in another function, and when I find a field of interest, like ‘text’, I know that the related content of that field is one cell ahead, ready to be used (because the json string is structured that way).
Nothing more, nothing less, no libraries, so naive.
This is what I get if I print the elements of that list


user paraimpu text Hi Twitter buddies created_at Wed, 05 Oct 2011 13:45:03 +0000

 

Here is the code for processing (Java derived language) but you can quickly understand how to replicate it in other languages.

http://pastebin.com/MTY0JPXW 

I’m still messing around with Paraimpu’s functionalities.