While in my attic one summer day I found an old toy from my childhood that didn't work anymore. As it had a little 5 key keyboard on the top I decided it would be fun to turn it into a MIDI controller.
The MIDI control is all done by a micro-controller on a perfboard inside the box. The micro-controller I used is a atmega328p, the reason being that they're easily programmable in Arduino C which was the simplest language to use for the project.
The toy is built into a box, with each side having a different mechanical control panel meant for the child to play with. On two of the sides there is a five key keyboard and three vertical switches. These were all modified to play MIDI notes when pressed by gluing buttons underneath them and connecting these buttons to the micro-controller.
Another side features a mechanical wheel which was similarly modified to generate MIDI events when turned by gluing a potentiometer to the wheel.
A hole drilled in another side of the box has a MIDI jack to make the connection between the box and the computer via a MIDI to USB cable.
The micro-controller simply polls the inputs connected to all the buttons and potentiometer. When one of the MIDI controlling inputs changes states, it sends MIDI data out of the MIDI jack which is connected to the micro-controller's internal UART bus. By connecting a standard MIDI to USB cable between the jack and a USB on a computer, the computer can receive this data. The data is interpreted in Ableton Live using a custom max device programmed and designed by @ehrenjn. The max device presents a GUI which allows the user to map each of the buttons or knobs to any key presses or knobs in Ableton Live. This gives the user a great deal of control over what the MIDI box can do.
A red LED that was already part of the toy is used to indicate power. The power is turned on and off by a switch on the side of the box. When the device is off and the switch is thrown, a nor latch latches the power on. When the switch is thrown again, the micro-controller senses this and latches the power off.
The box originally had a battery holder for two AA batteries which was replaced with a 9V battery holder to power the whole device. The 9V battery feeds into a nor latch built with discrete NPN transistors which controls power to the micro-controller as follows: When the device is off, one side of the latch is continually powered, generating a digital signal to tell the 5V buck converter to remain off. When the device is turned on by turning the on switch, the latch switches sides to activate the 5V buck converter, to power the micro-controller and the rest of the circuit. When the switch is thrown again, the micro-controller now senses this and latches the circuit back into it's "off" state.
How long does the battery last while the device is off? The entire circuit is measured to draw about 200uA while off, which makes sense given the voltage regulator's data sheet says it draws about 50uA while off, and 9V across on the 100K resistors in the latch circuit draws about 90uA. With a 500mAh 9V battery, the battery is estimated to last for about 500000/50 = 2500 hours (about 3 months) while off.