Introduction: Arduino Keyboard Learning Lights Attachment

Picture of 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

Step 1: Circuit Design

Picture of 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

Picture of Arduino Code
There will be a few changes you will have to make to the Arduino code before you will be able to upload and use it (unless your electronics are exactly the same as mine, which is unlikely). The code can be downloaded from GitHub here.

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.
Once you have made all these changes you should be able to upload this you your Arduino and move on to making the electronics.

Step 3: LED Strip

Picture of 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

Picture of 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

Picture of 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.

Comments

F.ZAMPIVA (author)2016-01-21

How you connect the Midi conector into arduino?

I mean.. what pins of arduino you use?

lcoetzee1 (author)2014-06-27

I am fairly new at this and was wondering how much harder this would be if i wanted to the same thing for my 49 key midi keyboard. Also this is a truly cool project you achieved here.

DanNixon (author)lcoetzee12014-06-28

Other than the additional LEDs the hardware would not have to change, as you can drive up to 64 (8x8) LEDs from one matrix driver IC.

lcoetzee1 (author)DanNixon2014-06-29

You seem like a pretty smart guy, what do you think the best way is to set up 49 keys in a row? Because I will need to have at least 6 dedicated rows? And also where do you get all your equipment from if you don't mind me asking

DanNixon (author)lcoetzee12014-06-29

If you are just using a matrix driver similar to mine then have groups of consecutive LEDs connected by either their anodes and every 8th LED connected by cathode (in reality the polarity isn't that important here, just make sure to wire them to the driver correctly).

90% of my parts and tools are from Farnell (including sub companies), Mouser, Proto-PIC, Thomas Graham's (local engineering supplier) and Screwfix.

lcoetzee1 (author)DanNixon2014-07-01

Okay thanks man, going to order the parts i need as soon as possible and i hope all goes well! :)

lcoetzee1 (author)lcoetzee12014-07-03

Last thing, I just don't want to blow anything as I'm going to have to do a lot of soldering. The arduino page doesn't really cover how to select Rset as well as I'd hoped. Could you elaborate a bit more?

DanNixon (author)lcoetzee12014-07-03

The page here (http://playground.arduino.cc//Main/MAX72XXHardware...) has a lookup table of LED current and voltage, you should find those on the datasheet for your LEDs.

lcoetzee1 (author)DanNixon2014-07-09

Hey there again, sorry to bother you so much but i really don't want to break something, so i just want to double check everything. What pins did you use on your arduino to the MAX chip? And also do you mind helping me out and sending me the your complete? Because i see you have header files in your github upload that aren't included? Thanks a lot for the help

DanNixon (author)lcoetzee12014-07-12

Data 4, clock 3, load 2.
This is configurable at the top of KeyboardLights.ino.
Also the other files are for libraries, you will need to have them in your sketchbook for it to compile.

lcoetzee1 (author)DanNixon2014-07-17

Thanks for all the help man. I have mine built and coded. Does not work as of yet, do you know what channel we use for the lights in synthesia?

DanNixon (author)lcoetzee12014-07-18

I believe it is configurable, been a while since I used it.

I also think you can set the MIDI library to get data from all channels.

About This Instructable

5,409views

15favorites

License:

More by DanNixon:Arduino Keyboard Learning Lights AttachmentGoogle Play Music Internet Radio (Raspberry Pi and Arduino)Arduino Web Enabled RGB Lighting
Add instructable to: