The Box of Mystery is made up os two music components.
The new module in the Box of Mystery / Broomstick guitar are the Infra-Red beams that are used to make virtual strings. Each beam consists of an Infra-Red LED and detector. I drilled holes in some 3/4 inch square stock and hot glued them in-place. Two resistors are used to create a 2.5 volt reference and the cathodes of the detectors are wired to it. Each anode is connected to one of the analog inputs on the Arduino.
Six regular LEDs are used to show which string is currently playing and the six IR LEDs are wired as a 3 by 4 matrix.
The mouse interface uses D2 and D4 for one mouse. D3 and D5 can be used with a second mouse. To fit inside the box I cut the top off the mouse. For the Broomstick Guitar, I removed the mouse and added a couple of USB connectors that can be used with PS/2 compatible optical mice.
The software for this project is made up three source files. The main one is musicbox_broom.ino. To use this software create a folder called musicbox_broom and download the three files into it. Then open the musicbox_broom folder in the Arduino IDE.
The mouse and Midi interfaces are the same as for the Mouse Organ. The PS/2 clock signal goes to one of the interrupt pins and the data signal goes to D4 or D5.
The Infrared photo diodes create a small voltage when the Infrared LED opposite is turned on. The analog input can measure this voltage. Each Infrared LED light can be seen by several IR photo diodes, so when the software is reading the voltage of each IR photo diode it only turns on the IR LED that is opposite. When an object is between the LED and detector, there is a different voltage and the software knows that the beam is broken.
This project uses twelve LEDs, six IR ones and six visible light ones. To minimize the number of digital I/O pins used, the LEDs are arranged in a three by four matrix. To light an LED, one of the columns is set LOW and one of the rows is set HIGH.