loading

Hi, this post is created by Jesus Alberto Cejas and Pablo Javier Ruiz to show you our Project about a musical keyboard, beautiful lights and Arduino.

This project was for 'Creative Electronics', a Beng Electronics Engineering 4th year module at the University of Málaga, School of Telecommunications (www.etsit.uma.es).

When teachers said “you have to make something with Arduino” we thought we had to make something to touch, with lights and sound.

Therefore, we have developed a decorative lighting system controlled by Arduino in relation to a musical performance on a key.

To explain how we have make this, we’ll split the project in 4 steps:

1.- MIDI communication and its reception on Arduino

2.- Lighting system and TLC5940.

3.- Operating modes.

4.- Description of codes.

Step 1: MIDI Communication and Its Reception on Arduino

We don’t explain all about MIDI. We’ll only use Note On and Note Off commands and its parameters, the pitch and the velocity (from 0 to 127).

To receive Midi commands in Arduino we have to condition the Midi signal (via 5-pin wire), which is current so Arduino can interpret Midi messages.

We use an octocoupler like 6N138. You can view the setting in the picture above.

So, we can read the Midi messages on Arduino using MIDI Library.

Step 2: Lighting System and TLC5940.

To control 12 LEDs (12 basic musical notes) we use a LED driver, in this case, TLC5940.

To use this driver, we have to connect the driver to Arduino (setting in the picture above) and will use his Arduino library.

We’ll use 1 to 12 outputs.

Step 3: Operating Modes.

We have developed two different modes to turn on the LEDs.

One of them is Continued mode and the other one Musical mode.

Continued mode

The LEDs will turn on in sequence, from the LED 1 to the LED 12 when you play the keyboard. The LEDs will turn off when you release the keys. For example:

You press Do (C) and the LED 1 turn on. You don’t release Do (C) and press Fa (F). Therefore, LED 2 turn on. LED 1 turn off when you release Do (C) and LED 2 turn off when you release Fa (F).

Musical mode

Each LED is assigned a musical note: LED 1 – Do (C), LED 2 – Re (D), LED 3 – Re# (D#, …, LED 12 – Si (B).

For example, if you press any Do (C) key, LED 1 turn on. If you release the key, the LED 1 turn off.

To switch from one mode to another we use a switch connected to a digital input on Arduino.

Step 4: Description of Codes.

In setup function we open the serial port and set the velocity (31250 baudios is the Midi communication velocity), assign the handles to Note on and Note off messages and initialize TLC5940 driver.

In loop we read Midi port waiting a Midi message. When we catch a Midi message run the corresponding handle.

If we have read a Note on message turn on the corresponding LED and update the counter (only in Continued Mode).

Conversely, if we have read a Note off message turn off the LED.

Step 5: Thanks

Thanks to:

-Teachers of the ‘Creative Electronics’ for your help in adapting the MIDI signal.

-Manuel Talavera for lending us a welder which saved our lives :D.

-Antonio Guerra for record and edit videos.

-Gala Garrido for agreeing to play the piano.

This is all. We hope you like it.

<p>hello </p><p>Your project is great! in the schematic with the tlc5940 and the arduino there is a problem with the resistor and capacitor values, could you tell me the values? and also what does the arrow symbol between two traces in the optocoupler mean?</p><p>Thank you</p>
<p>Hi chuisco!! We glad you like it.</p><p>First, the resistor that is connected between 20 and 22 pins of the TLC5940 is a 2k ohm resistor. In practice we don't use the capacitors (which ensure a stable power supply) so that we can't guarantee the capacitors values.</p><p>Second, I think the arrow symbol which you comment is a diode connected between 2 and 3 pins of the optocoupler (anode in 2, cathode in 3).</p><p>Regards!!</p>
<p>I love the visual to go along with the music! Very cool!</p>
<p>We glad you like it. Regards!!</p>

About This Instructable

3,369views

52favorites

License:

More by Jesus Alberto Cejas:MIDI controlling lights Arduino 
Add instructable to: