Friday, May 24, 2013

Circuit Bending Basics 7: MIDI-controlled Toy Pitch / Speed

This post assumes that you are familiar with the previous Circuit Bending Basics Posts.

Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!

Digital Pot and Toy Control
This article is based around the MCP4212 digital pot and the Teensy - so if you're not familiar with either, please visit the Teensy website,  read up a little on Arduino coding and check out my Teensy Basics series of posts. Also, be sure to check out the MCP4212 tutorial.

This article will provide a simple framework that can be used to control the pitch / speed of a toy using MIDI pitch data. The higher the pitch, the higher the speed of the toy.

In general, the process is like this:
• Build the barebones MCP4212 and Teensy setup as shown in the tutorial
• Find the clock resistor of a toy that you wish to control
Remove the resistor
• Connect the two resistive points on the toy's circuit to the P0A and P0W pins of the MCP4212
• Write some code to control pot 0 of the MCP4212 via MIDI

Connecting the Digital Pot to the Toy - Example
Once again, we revisit the musical mat toy from the previous Circuit Bending Basics.

The resistor in this particular toy is simple to remove. The two resistive connections on the board were soldered to two white wires, which were then connected to P0A and P0W pins of the MCP4212.

In the first image, these connections are highlighted in purple. 

Writing the Code
The code takes the pitch value of a note-on MIDI message, and sends that value to the digital pot. The digital pot then sets this as a resistance.

The code uses the same SPI library as in the MCP4212 example. The code uses the same user-defined MCP4212 function as in the MCP4212. The changes in the fact that the usbMIDI functions are connected to the digital pot.

Download the code here:

Example Video