Optical Mouse Cello

Using two optical mice and an Arduino microcontroller, I have built a Midi Cello. In other projects I have said how easy it is to make these types of projects and this time I really worked at keeping it simple. The two mice are wired to the Arduino Uno or Mega microcontroller and the serial out is wired to a 5 pin Din socket with 2 100 ohm resistors to provide the current limit for the Midi data out and thats it !

IMPORTANT! This project uses PS/2 compatible optical mice. The mouse should have either one of these types of connector.

Hopefully you will feel inspired to start making your own devices. The components for this project cost around $65. The electronics was bought at RadioShack and the wood was bought at Home Depot. A battery powered screwdriver/drill. a hot glue gun and a saw are tools you probabally already own. If you are going to do electronics then a soldering iron, a pair of thin nose pliers and a pair of side cutters are needed.

The finger board slider was made by cutting a piece of 3/4 inch plastic pipe in half down its length. The slider is just a piece if 3/4 wooden dowel.

Thanks to

Moog Music

Bob Moog Foundation
for inspiring me to get back into doing electronics last year (2012).

The Cello uses two PS/2 compatible optical mice. The PS/2 hardware uses four wires: +5v, 0v, clock and data. The clock wires are connected to digital IO pins that can generate software interrupts. On the Arduino UNO these are D2 and D3. The data wires are connected to digital IO pins D3 and D4. The serial transmit data pin TX is connected to a couple of resistors and the midi out connector.

Once they have been initialized, the mice send X and Y data as they detect movement. The optical sweet spot for the mice is small and the moving pieces need to be kept in it. For the bow sensor a bow rest is glued to the mouse and a backstop keeps the bow against the mouse. For the finger board sensor, a piece of plastic pipe that has been cut length ways is used to keep the slider which is made from a piece of dowel, aligned with the sweet spot.

The software that runs on the Arduino is based on software that I have written for the midi guitar, the Aniversal midi controller and the Doodlebug midi to keyboard convertor that can be used to play the Google Doodles.
cello.cpp
This is the main software that controls the arduino (ATmega 328P) based controller.
ps2a.h
This file is included into cello.cpp and provides the function that writes to the mice.

Most of the Midi software I develop has a #define DEBUG 1 commented out near the top. When this define is un commented, the serial port speed is set to 9600 baud and debugging info is output instead of the midi data. Use the serial monitor to display this information.

The cello software has two copies of the ps2 mouse code. One coded for interrupt 0 using D0 and D4. The other mouse is handled by interrupt 1 using D3 and D5. The bow functionality is handled by interrupt 0 and the slider is handled by interrupt 1.

There are two defines

#define MOUSE1 1
All the mouse 1 specific code is guarded by this define.
#define MOUSE2 1
All the mouse 2 (slider) specific code is guarded by this define.
When I first developed the second mouse code, I had a hard time making sure I used the correct variable names so I wrapped the mouse 1 code withe the #define MOUSE1 and then commented out the define. Once I had fixed the variable names, the second mouse worked great!.

When debugging, if you comment out MOUSE1 or MOUSE2 then the debugging output for that mouse is not output.

ps2setup()
Initializes the IO pins for clock and data and attaches the interrupt routine to the interrupt.
ps2interrupt()
Triggered by the clock signal on D2(D3) and reads the data bit (D4(D5) and constructs the 8 bit byte.
mousepoll()
Reads bytes from the msgbuf and handles the state of the mouse.
mdecode()
Decodes the 3 bytes passed from mousepoll.

 
radioshack logo
Arduino logo
http://www.computer-engineering.org/ps2protocol/
This document describes ps2 hardware specification.
http://www.computer-engineering.org/ps2mouse/
This documents the data and commands that the mouse sends and receives.
Page updated 5/15/2013