Introduction: Arduino Keyboard Learning Lights Attachment
I've started playing Synthesia a lot recently and thought it would be cool if I had one of those keyboards that supports the prompt/learning lights over MIDI, which Synthesia has an option to output, but buying a new keyboard is a little expensive for me, so I thought I would just build an add-on for my current keyboard (a M-Audio Oxygen8, a little 25 key MIDI keyboard; it's not much but it's enough for me).
I thought this would be a quick little project that I could do in a day or so, but a lot of that time was debugging etc., you could build this in a couple of hours depending on your soldering skill and patience (mainly patience, building the LED strip is a bit annoying).
Here is a (not particularly good) video demonstrating the project:
For some reason Instructables is not letting me embed the video so here is a YouTube link: http://www.youtube.com/watch?v=LfwVIxyaxYY
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Circuit Design
I had originally planned to use an Arduino Mega for this and drive an LED matrix directly, but when looking through my spare parts I found a MAX7219 matrix driver (left over from my coffee table) so I thought I would use this instead and build it onto a shield for a standard sized Arduino (Uno, etc.).
The first schematic gives a rough idea of how I wired the LED matrix to light individual keys, although my final matrix didn't quite turn out like this so you may need to edit the Arduino script to match your matrix configuration (as long as the matrix works it doesn't matter what LED lights a key as that is fully configurable in software, you will see what I mean in the next step).
The second schematic is taken from the Arduino Playground page for the MAX72xx range, where you will also find a guide to choose a value for the current limiting resistor RSet.
Step 2: Arduino Code
All the parts of the code are found at the top of the code, this includes pin configurations, transpose settings and LED indexes for each hardware key:
- Button pin configuration (lines 4 and 5)
Set these to the pin which is connected to your transpose buttons, these pins are pulled high by the Arduino and should be pulled to ground by the buttons.
- MAX7219 pin configuration (lines 6 to 9)
Set these to the respective pins on the MAX7219: DATA_PIN should connect to pin 1 of the MAX IC, CLOCK_PIN to 13 and LOAD_PIN to 12.
- Transpose settings
First set the transposeMax and transposeMin to their correct values, this is the number of valid times you can transpose the keyboard in each direction (e.g. my M-Audio keyboard lets me transpose +/- 4 octaves) (note transposeMax must be positive or 0 and transposeMin must be negative or 0).
Secondly set the midiStartPoints to match your transpose settings, this is an array of integers corresponding to the MIDI note which is produced by the leftmost key at each transpose setting (note this array must be of size transposeMax-transposeMin+1).
- LED indexes
This is an array which defines the row and column for each LED, ordered by keys from left to right (note the size of this array must be equal to the number of keys on your keyboard and each element must be an array of size 2).
- MIDI channel
By default the Arduino is set to pick up note messages on all channels, however you may change channel used to listen on on line 100 of the sketch.
Step 3: LED Strip
This can be a little tricky to get correct right away (I had to desolder quite a bit of mine) but essentially what you want to do is produce a linear LED matrix, it is difficult to explain how I did this so I hope the drawing will give you an idea, essentially you take each row and put it next to the other and every 8th LED shared a common anode and every set of 8 LEDs share a common cathode.
Looking back I should have really made a video showing the process of soldering this, let me know if you want me to try to explain this better.
Step 4: Driver Shield/PCB
Designing the driver shield should not be too difficult, I managed to lign up the MAX7219 ground pin with an Arduino ground pin on the stripboard however most of the other connections must be made using wire links, the two tactile buttons were only soldered in using two pins (they were used so it was diccicult to clean all the pins to they would go though the holes in the stripboard).
You do not have to use a IC holder if you don't wat, but it makes it easier if you decide you need the MAX IC for another project, even if you have to make do with a 28 pin IC socket like I did.
I did consider using .1" pin headers to connect the LED strip to the driver sheild, however did not think this had a lot of benefits, although it would allow you to use it as a generic matrix driver shield if you wanted. All I ended up doing was soldering the wires form the LED strip directly to the driver shield.
The MIDI socket I claimed form my MIDI accordion project (it would be easy to put a new port on the accordion), it is just a panel mount one but you could use a PCB mount one and have it soldered directly on the driver shield if you like (this is probably a better solution) .
Step 5: Assembly and Test
The last thing to do is plug the shield into your Arduino, load the sketch (if not already done), mount the LED strip on your keyboard (I used the magical adhesive which is Blue Tack), connect your note prompt MIDI cable and try it out.
For initial testing I just connected the input of the Arduino to the output of the keyboard, this will allow you to properly test the key configs, when doing this expect a key to light up when it is pressed. If all is good here then have a go playing using the prompt lights, you may or may not find it easier, I suppose this type of prompt would be useful for some but not for others, but it is an interesting project to build it anyway.