Introduction: Mouse Organ / Mind Exploder
Step 1: Software
In this step I will discuss the software that runs on the Arduino controller. The source is available from my website http://moddersandrockers.com/mouseorgan/ The two main files are the mouseorgan.ino and mouse1.ino The file mouse1.ino handles the communication with the PS/2 mouse. It has a setup function called ps2_setup() and two utility functions. ps2hostpoll() handles sending commands to the mouse and mousepoll() handles receiving and decoding of the data from the mouse. In the end you get three variables ;- mx which tracks the X position of the mouse and my which tracks the Y poition of the mouse. The variable mswitches has the on/off state of the three mouse buttons as the bottom three bits. The image on this page shows the main part of the software loop. This small piece of code uses the X value and the state of the mouse buttons to decide what note to send and when to send the note off command. It also resets the X and Y values when the middle button is pressed.
Step 2: Testing and Debugging
One of the hardest parts of a project of this type is testing and debugging. Mistakes are made, and fixing them can be a challenge. On the hardware side, the wiring to the mouse and the Midi connector can be an issue. The simplest to test is the Midi output. A simple test program can be used to check the Midi output. The first image on this page is a simple Midi output test program that plays the same note once a second.The source for the midi test program is available here http://moddersandrockers.com/mouseorgan/source/miditest.ino When uploading programs to the Arduino, you should unplug the midi cable since the midi device can mis-understand the data and put the Midi device in an odd state. Once uploaded the midi test program should play a note once a second in time with the led on the board. If the light flashes but the note does not sound, try swapping the wires on the midi connector. Check that the other end of the midi wires go to the TX pin on the arduino and to the +5 volt pin. A USB PS/2 compatible mouse is the easiest to use. I have rescued the USB front panel connectors from an old desktop and wired it to the pin header. So I can just plug in the mouse. A USB style mouse must work with a PS/2 adaptor. Some modern USB mice no longer support the PS/2 adaptors and only work in USB mode. Radioshack sells a wired mouse that says it is PS/2 compatible and I have also used a wired mouse I bought at Staples.
We have a be nice policy.
Please be positive and constructive.