Mouse Organ / Mind Exploder

4.1K189

Intro: Mouse Organ / Mind Exploder

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.

9 Comments

Nice project. Please, give more details about the mechanical parts. Thank you!

Hi, I will see what I have and make a better build it sequence.

Thank you very much! I will to wait.

Hi, I'm trying to use the program that interprets the mouse movements for my own project, but when I try to compile, I get these errors:\

mouse.ino:36:13: error: 'MSGSIZE' was not declared in this scope
mouse.ino:37:14: error: 'MSGSIZE' was not declared in this scope
mouse.ino: In function 'void ps2interrupt()':
mouse.ino:88:5: error: 'msgbuf' was not declared in this scope
mouse.ino:90:20: error: 'MSGSIZE' was not declared in this scope
mouse.ino: In function 'void ps2send(int)':
mouse.ino:102:36: error: 'outhex' was not declared in this scope
mouse.ino: In function 'void ps2DebugPrint()':
mouse.ino:114:19: error: 'outhex' was not declared in this scope
mouse.ino: In function 'void baddata(int)':
mouse.ino:341:14: error: 'outhex' was not declared in this scope
mouse.ino: In function 'void mousepoll()':
mouse.ino:398:14: error: 'msgbuf' was not declared in this scope
mouse.ino:401:19: error: 'MSGSIZE' was not declared in this scope

Do you have any suggestions?

Hi, first create a folder called mouseorgan and then download and save the mouseorgan.ino file into it. Then download the mouse1.ino and tunes.h into the mouseorgan folder. In the Arduino program, select file/open and select the mouseorgan folder. mouseorgan.ino has the missing pieces that the mouse1.ino was complaining about.

Hi, I will have a look at my setup. There are three files that you need to download from the webpage. I first downloaded mouseorgan.ino and saved it in a folder called mouseorgan, then I downloaded mouse1.ino and saved it in the same folder and then the tunes.h and saved that in the mouseorgan folder. The macro and functions listed above are in the mouseorgan.ino file.

can it be done with wireless mouse?
It can be done using a wireless mouse. The current wireless mice are mostly USB based with a dongle/micro transceiver. The Arduino UNO does not know how to talk to them but I have used a RaspberryPI which can talk to USB mice and used the I2c interface between the RaspberryPI and the Arduino. So I used a RaspberryPI as a USB to Arduino adaptor :)
excuse me but can you put mor details on how to build one of this please XD i want to do it but with the explanation here and on the oficial website i still don't understand how to build one of this, so if you can put step by step on how to do it i would really apretiate it :D