Introduction: MIDI Controlling Lights Arduino
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.
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).
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
-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.
We have a be nice policy.
Please be positive and constructive.