This tutorial provides information on how to build and program a basic MIDI interface to control a recording light by Logic Pro X. The image shows a block diagram of the entire system from the Mac computer running Logic Pro X on the left to the SainSmart Relay that will be used to turn the light on and off on the right. Logic Pro X uses a feature called control surfaces to send MIDI data when recording is started or stopped. A USB to MIDI cable connects the computer to the MIDI interface to carry the signal. The interface uses a 6N138 optoisolator chip to physically separate the MIDI input from the computer and the output to an Arduino Uno controller board. In addition to the hardware and schematic diagram of the MIDI interface, we will discuss the program or "Arduino sketch" uploaded to the Arduino controller board used to interpret the MIDI signals from Logic Pro X and subsequently turn the relay on and off.
I'll be posting two accompanying videos covering this project on my YouTube Channel (Chris Felten), which could be of help in building the project. I will also embed them at the end of this tutorial. Also check out the references on the last page of this instructable, which will be extremely helpful in better understanding MIDI and the interface circuit.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Schematic
The MIDI input on the left is oriented as if looking form the back of a female, chassis mounted MIDI connector where the wires will be connected. So the front receptacle of the MIDI connector is pointing toward the screen. Pin 4 of the MIDI connector is connected to a 220 ohm resistor, which is connected to the banded side of a 1N4148 diode and to pin 2 of the optoisolator. Pin 5 of the MIDI connector is connected to the diode opposite the banded side and to pin 3 of the optoisolator. Make sure to locate the band on the small diode and orient it correctly!
Notice that the Arduino Uno controller board provides a 5V output that is used to power both the optoisolator chip at pin 8 and the SainSmart 2 Channel Relay Board at the VCC pin. The Arduino Uno ground ties into pin 5 of the optoisolator and the GND pin of the SainSmart Relay Board. Pin 7 of the optoisolator is tied to ground through a 10,000 ohm resistor. The output of the optoisolator at pin 6 is connected to pin 2 of the Arduino Uno. Some other similar circuit schematics may show it going into pin 0 of the Arduino, but our particular sketch (program) assigns the input to pin 2. Output pin 7 on the Arduino Uno connects to the IN1 pin of the SainSmart relay board.
The jumper on the SainSmart Relay Board should remain in place. The relay output is between the two screw connectors as shown. When the appropriate MIDI signal is received, the Arduino Uno will make pin 7 positive (high) thereby instructing the relay to close and completing a circuit between a light and its power source and turning the light on. You may want to use a low voltage light so as not to have to bring 110V AC into the MIDI interface enclosure, though I believe the SainSmart Relay Board used in this project is rated for 110V AC.
The Arduino Uno is powered through a barrel connector built onto the board. A standard 9V wall mounted power supply should suffice. Most of these will come with multiple barrel tips, one of which will accommodate the barrel connector on the Arduino.
Step 2: Parts List
Parts List for the MIDI interface recording light:
MIDI connector: Digikey CP-2350-ND
220 Ohm 1/4watt resistor: Digikey CF14JT220RCT-ND
1N4148 diode: Digikey1N4148-TAPCT-ND (Alternates:1N914, 1N916, 1N448
10k Ohm 1/4watt resistor: Digikey CF14JT10K0CT-ND
470 Ohm 1/4watt resistor: Digikey CF14JT470RCT-ND (I used 2x220 instead)
6N138 Optoisolator: Digikey 751-1263-5-ND (Frys - NTE3093 Part#: 1001023)
Arduino Uno - R3+: OSEPP (OSEPP.com) and Frys: #7224833
SainSmart 2-channel 5V Relay Module: This can be found on Amazon. You could substitute a solid state relay with input of 5-12V for silent operation in the studio. The physical relay is loud.
Bread board: Fry’s Electronics or other
Jumper wires: Fry’s Electronics or other. I use SchmartBoard - http://schmartboard.com/wire-jumpers/
9V DC wall adapter power supply: Fry’s or other (Usually supply 600-700mA, often can be adjusted to provide different voltages 3-12 volts and come with different tips. Example: Fry’s 7742538)
USB cable A-B: Used to connect your computer to Arduino board to upload the sketch (program). Fry’s Electronics or other
Enclosure: Fry’s Electronics or other. I used a box from Michael’s Arts and Crafts Shop.
Nuts, bolts and spacers to mount boards: Fry’s Electronics or other
Recording light: Any light will work. Preferably something with a low voltage supply so you don’t have to run 110V AC into the midi enclosure relay. I used a battery operated, red, emergency light I found cheap at fry’s, but you may want something fancier.
Step 3: Arduino Uno
On the left of the Arduino Uno board is a barrel connector for a 9V power supply. A simple wall mounted power supply should suffice (see parts list). The large metal port above the power connector is the USB port for a USB cable A-B. This connects the Arduino Uno to your computer so the sketch (program) can be uploaded. Once the program is uploaded to the Arduino Uno, the cable can be disconnected. Note that you will want to mount the end of the Arduino Uno board with the power connector and USB port close to the side of the enclosure, so you can cut openings and have easy access to the them. You will be using the 5V pin and GND pins along the bottom of the picture to provide power to the 6N138 optoisolator chip and the SainSmart Relay Board. Pin 2 receiving the optoisolator output and pin 7 going out to the relay are at the top of the picture. SchmartBoard makes jumper wires, headers and wire housings that can be connected into the Arduino Uno board. These headers and prefabricated jumper wires of different lengths make it easy to attach the different modules and may save some solder time. If you have a Fry's Electronics nearby, you can browse the aisle where they have the Arduino devices and other small projects or robotics to get an idea of the headers, jumper wires and connectors available. Also check out: http://schmartboard.com/wire-jumpers/
Step 4: SainSmart 2-channel Relay Module
The output from pin 7 of the Arduino Uno connects to the IN1 pin of the SainSmart Relay Board on the left of the picture. The 5v supplied from the Arduino Uno connects to VCC. The GND pins of the Arduino Uno and SainSmart Relay Board should also be connected together. The jumper on the SainSmart Relay Board remains in place as shown in the picture. The relay output is the top two screw connectors on the top relay as it is oriented in this picture. The two screw connectors are on the top right of the picture. One screw connector is connected to the light, which is then connected to one side of the light's power source and then back to the other screw connector on the relay so that when it closes, power is supplied to the light and it illuminates. I connected the relay output screws to a 1/4" phono plug mounted on the enclosure, which is then connected to the actual light and it's battery power source. That allows me to easily disconnect the light from the interface enclosure.
This SainSmart Relay Board is a physical relay, so it is somewhat loud in the setting of a recording studio. A quieter option would be to use a solid state relay instead.
Step 5: Brief MIDI Overview
MIDI – Musical Instrument Digital Interface
NOTE: For a more detailed explanation of MIDI check out Amanda Gassaei's Instructable on the topic:
This is a brief overview of the MIDI format that should help to understand how the Arduino sketch (program) uses the MIDI data sent by Logic Pro X to control the relay and subsequently the recording light.
MIDI information is sent in bytes, which are composed of 8 bits (‘xxxxxxxx’).
In binary, each bit is either a ‘0’ or a ‘1’.
The first byte is a Status or Command byte, such as ‘NOTE-ON’, ‘NOTE-OFF’, ‘AFTERTOUCH’ or ‘PITCH BEND’. The bytes that follow after the Command byte are Data bytes to provide more information about the command.
Status or Command bytes always start with 1: 1sssnnnn
Command bytes hold data for the command in the first 4 bits (1sss) and the channel in the last 4 bits (nnnn).
Let’s use a ‘NOTE-ON’ Command byte sent on channel 2 as an example:
If the Command byte is: 10010001
The byte starts with a 1 and is interpreted as a Command byte
Knowing this is a command byte, MIDI takes the first half as 10010000
This = 144 in decimal, which is the command value for ‘NOTE-ON’
The second half of the byte is then interpreted as 00000001
This = 1 in decimal, which is considered MIDI channel ‘2’
Data bytes will follow Command bytes and always start with 0: 0xxxxxxx
In the case of a NOTE-ON Command byte , 2 more Data bytes are sent. One for PITCH (note) and one for VELOCITY (volume).
Logic Pro X recording light control surface sends the following MIDI data when recording is started or stopped:
Started (Light on): Command byte ‘NOTE-ON’/MIDI Channel, Pitch byte ignored, Velocity byte = 127
Stopped (Light off): Command byte ‘NOTE-ON’/MIDI Channel, Pitch byte ignored, Velocity byte = 0
Notice that the MIDI Command is always ‘NOTE-ON’ and it’s the Velocity that changes to turn the light on or off. The Pitch byte is not used in our application.
Step 6: Arduino Sketch (program)
The attached document is a pdf file of the actual sketch loaded into the Arduino Uno board to run the MIDI interface. There is a MIDI tutorial written by Staffan Melin that served as the basis for this sketch at:
You will need to download the free Arduino software on to your computer (https://www.arduino.cc/) in order to edit and load the sketch into the Arduino Uno board using a USB cable A-B.
I also created and posted two tutorial videos on my YouTube channel (Chris Felten) that go over this project and explain the Arduino sketch in more detail. If you're interested in building the MIDI interface and programming it, the two associated videos may be of help.
Step 7: Completed Interface
I chose to house the MIDI interface in a wooden box from Michael's Arts and Crafts. While convenient and inexpensive, the wood box works like a percussive instrument when the physical relay switches! A solid state relay would be a worthwhile improvement to get rid of the switching noise.
Notice the Arduino Uno connections at the end of the box on the left. Holes were cut to give access to the USB port and the power connector. The female chassis mount MIDI connector can also be seen at the end of the box.
There is also a picture of the inside. While the project could easily be wired together on a perforated breadboard, I had spare copper clad board and etching material so I created a printed circuit board for the project. I used prefabricated jumper wires and headers from SchmartBoard (http://schmartboard.com/wire-jumpers/) to connect the interface board, Arduino Uno and SainSmart Relay board .
Step 8: Logic Pro X
Logic Pro X has a feature called control surfaces. One of these is a recording light control surface that once installed will send MIDI signals when recording is armed, started and stopped. You can install the control surface by clicking on 'Logic Pro X' on the top menu bar followed by 'Control Surfaces' and 'Setup'. This will open a new dialogue box. By then clicking on the 'Install' drop down, you can find the Recording Light control in the list and add it. It is well worth taking a look at my MIDI Controlled Recording Light video on YouTube to get a full explanation of how to set up the Logic Pro X Recording Light Control Surface parameters to work for this interface.
Step 9: Helpful References
Send and Receive MIDI with Arduino by Amanda Gassaei:
Arduino and MIDI in tutorial by Staffan Melin:
Accompanying videos embedded here can also be found on my YouTube channel: Chris Felten