Arduino + 4066 chip to control circuit bent instruments from Max / MSP

Hello,

i'm working on a project which involves controlling the functionality of modified toys/instruments from a laptop i.e. the laptop can trigger sound playback etc. I'll explain how I achieve this:

I open up a toy and poke around the circuit board until I find two points which, when connected together using croc clips, trigger one of the sound functions of the toy. I solder wires to each of these points (POINT A + POINT B), and feed them out of the casing, so that I can trigger the sound by touching the ends of the wires together - instead of pressing a button already on the toy.

To have this operation controlled electronically, i need an electronic switch. I've been using the 4066 chip, which is essentially 4 independent SPST switches. Using a breadboard, i can connect POINT A to one pin on the 4066, POINT B to another pin on the 4066, and then 'close' the switch by supplying a 'control voltage' to another pin on the 4066. When the control voltage is supplied, the switch closes, current runs from A to B, and the sound is triggered. Lovely.

The control voltage comes from the Arduino digital output pin. When i turn a certain pin ON, a 5V voltage is sent to the necessary pin on the 4066, and a switch is operated. I'm using an Arduino Duemilanove btw. I'm using Max / MSP to drive the arduino - this way i can write various programs to trigger sound play back in which ever way i like e.g. i can use an analogue keyboard like a MIDI keyboard.

By the end of the project, i aim to have around 10 modified toys/instruments being simultaneously controlled from the laptop. This way I can write a program in Max/MSP which can 'play thru' a composition using these instruments... and i can just sit back and watch. This is all a pretty simple overview, but i will explain in more detail if requested.

My question:

A single arduino has 13 output pins, meaning i can control 13 switches (thus can control playback of 13 different sounds). Ideally, i aim to have in the region of 50 different sounds available for playback, therefore i require 50 independent digital output pins. Am i best using multiple arduino boards - or should I investigate an alternative micro-controller?

All I am using the arduino for is the 5V output to operate the switches in the 4066. If there is a different micro controller available that has more output pins capable of this 5V - as well as being compatible with Max/MSP - then I would prefer to use that! But as yet, i cannot find one. Any suggestions?

Thanks, and sorry if this doesn't make sense just yet, it's late and i'm tired!

Jordan

PS- For anyone interested, here is a previous performance I was involved in using circuit bent instruments. Here we 'manually' operated our instruments. I did, however, circuit bend a Nintendo Entertainment System, which was controlled by a laptop in the exact same fashion as described above. Glitches are automatically turned on and off according to a Max / MSP program which was running live. The output of the NES is projected behind us. At times, the NES is programmed to glitch 'in-sync' with the music. WARNING: circuit bent music may not be to everyone's taste!!

You could use the analog pins as digital pin as well but for loads of pins
shift-registers or I2C-port-expanders may be more interesting.

At the cost of 3 pins one 74HC595 shift-register (many others exist) will give you 8 output-pins.
By connecting 595s in a so called daisy-chain you can control many 595s using just those 3
arduino-pins. In theory you could control as many as you want and wit a bit of luck you may
find 'm for ~$0.30 a piece...

I2C is often a bit more expensive, it uses 2 pins of the arduino. You can drive several
port-expanders using the I2C bus. I2C can be used for loads of different kind of chips,
which you'll need to address. The pcf8574 port expander for example can be set to respond
to 1 of 8 different addresses, each will give you 8 I/O pins resulting in 64 pins.
Since it comes in two versions it's possible to handle 16 chips/128 pins.

These are just two commonly used chips, many others exist.

Question may be whether they're capable of controlling bent-circuits, I'd guess you'll not always know
what voltages/currents can be present when circuit bending.

Hi, thanks for the reply. I was looking into shift-registers. Am I right in thinking that to get a certain pin ON, i need to 'count up' to that value by sending the correct amount of pulses through the arduino pins? This may get a little tricky when the values are constantly changing, though i could probably figure it out.

What I stumbled over today though may be a better solution: the Arduino Mega. It has 54 digital in/out pins, and I have spoken to a colleague who has used it successfully with Max/MSP. This would ideally be a neater solution to my problem, and would keep the programming side of things a lot simpler.

Does the Mega sound like a better idea, given my inexperience of electronics/micro-controllers?

You're right with the shift-registers, by sending 1 byte each pin will act as a bit.
With for example 8 registers in a chain... and wanting to play one sound you'll need to send
all 8 bytes of which one's changed again.
Constantly changing values isn't a very big problem for the arduino, it's capable of sending
new values within a few microseconds. I haven't worked with it yet, but there also is a
library which could take care of the tricky part. In the setup part you just tell how
many registers are connected and while working all you need to do is tell which
pin should be turned on/off. The library will remember (and resend) the settings of
all output-pins if you change one. You could also create your own solution and being able to program already is a serious advantage.

The mega-board indeed has 54 pins to use, you might be able to use it as well, it also has
8 times more memory and sounds... perfect for the job.
Whether it will be a good choice is a bit of a question given the nature of your project.
Micro-controllers, both small and large, aren't capable of handling much power.
A note/sound found may be playable for a while, but in time the controller may be ruined
if too much current flows.

In that case the mega 2560 has a serious disadvantage. Most smaller(memory/pins) arduino
controllers are DIP-based, you can quite easily take them out of their sockets and place
a new one should anything happen. The Mega2560-controller is a surface mounted device though,
you'll have to de-solder the old controller and solder a new one. That's pretty tricky to do,
before you know it copper-traces on the PCB may get damaged requiring you to buy a complete
new board. Even with very good solder skills replacing the controller more as 1-2 times will
very likely mean the end of a board.

If you would like to use one, it's possible, but I'd advice to use easy replaceable
opto-couplers or another technology as well to keep controller and project electronically
separated. Even though they're replaced a lot easier that... probably is a good advice
for dip-based boards as well.

i need to 'count up' to that value by sending the correct amount of pulses through the arduino pins?

No what you do is to have a variable with the bits in it corresponding to the output of your shift register or registers. To change a bit you alter it in the variable and then send it to a routing that outputs the whole variable to your shift register, the bits you have change at that moment change the others do not. Using your method you destroy the state of all the other bits just to change your one bit.