Introduction: Mouse Organ / Mind Exploder

About: Being doing electronics and computers as hobby/job for about 40 years and still having fun!
This is a simple project. It uses a PS/2 compatible Optical mouse and an Arduino to make a Midi controller. A 6 pin and a 4 pin header plus two 150 ohm resistors and a 5 pin Din socket complete the parts list. I use heat shrink tubing to protect the soldered joints. The software is available in source from http://moddersandrockers.com/mouseorgan I view this as just a component in a kit of musical building blocks that you can use to create a Mind Exploding array of instruments.
 There are many ways you can use the mouse to control what note is playing or adjust one of the controls on the Midi device. In the video, I have taken a piece of 3/4 inch plastic pipe and cut a flat area that just exposes the inside of the pipe. This allows you to glue the mouse so that it 'sees' a piece of 3/4 inch wooden dowl when it is put through the pipe. When using an optical mouse you find that the depth of focus of the mouse camera is very small and you need to keep the surface that is moving in the camera's sweet spot. Get creative!

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.
Weekend Projects Contest

Participated in the
Weekend Projects Contest

Musical Instruments Contest

Participated in the
Musical Instruments Contest

Arduino Contest

Participated in the
Arduino Contest