Adafruit Feather MIDI, Music and LEDs

In my last post using the Adafruit Feather, I described how to get the MIDI and Music Maker FeatherWings working together.  This time I’m adding in the CharlieWing LED module.

Warning! I strongly recommend using an old or second hand keyboard for your MIDI experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

The Circuit

Refer to my previous tutorial for details of putting these boards together – in particular recall (or note) that I’ve removed the “MIDI” pin from the Music Maker FeatherWing.

The Code

Starting from the position of having everything from the previous project up and running, this code adds in support for the CharliePlex FeatherWing as a MIDI note display.  As a reminder, this is how the various boards are linking together.

FeatherMIDIVS1053

The CharlieWing is programmed using I2C, but all the details are hidden by using the Adafruit IS31FL3731 library as described in the Adafruit CharlieWing tutorial here.

As noted before, occasionally I had problems uploading to the board but retrying or using the “reset” button at the start of the upload usually fixed everything.

Warning Note: My initial experiments were giving me a very laggy MIDI response.  In fact, at times it seemed like the MIDI note wouldn’t play until I actually raised the key rather than pressing it.  I think there were some MIDI messages stuck “in a queue” in the code somewhere, but never managed to work out where.  Whenever it got stuck in this mode it seemed that powering the whole thing off and on again (really!) seemed to resynchronise everything.

Apart from that, the additions to the code to talk to the LEDs was relatively straight forward.  The Adafruit GFX library makes driving the LEDs very easy with a drawPixel() function.

On powerup, I used the LEDs to indicate which MIDI channels were active to be passed onto the Music Maker Wing.  Then when that clears, it will light up as notes are played.  As there are 7 rows of 15 LEDs I decided to make each row an octave, starting from MIDI note 24, which is C1.

To work out which column to use, use the MIDI note number modulo 12.  To work out which row to use, use the MIDI note number (less 24, the value for C1) divided by 12.

note = note - 24;
int x = note % 12;
int y = note / 12;

LEDs are lit on receiving a MIDI Note On and turned off on receiving a MIDI Note Off.

Find it on GitHub here.

Closing Thoughts

This shows the basics of using the MIDI Wing to drive both the Music Maker Wing and the CharlieWing LEDs.  There are many options from this point onwards – alternative display modes; showing different information (e.g. channel usage rather than notes); adding some buttons or potentiometers to control the synth… even using a more powerful Feather main board that could generate sounds itself.

There are many other Wings to explore too, so I might do some browsing to see which others might have musical applications.

Kevin

Leave a comment