I'm sorry for the, perhaps, a bit blunt reply above - I've spent so much time on this project to suddenly find out in the end that it might be useless. Bare with my frustration please.
I have made 2 12 button samplers with lamps in each button.
They both run on an arduino UNO R3 with a waveshield 1.1.
My powersupply is 12 1,5v AA batteries in series (for 12 lamps), and there's an lc809cv voltage regulator that powers the arduino.
on the I2C bus i have an mcp23016 IO expander that turns on some of the lamps while also has some of the button inputs.
All the arduino pins that aren't used by the waveshield, is being used for either button inputs or outputs for triggering transistors to turn on/off lamps.
that means i'm using pin 0, 1, 6, 7, 8, 9, 15, 16 and 17 (the last three are analog pins initialized as IO's).
On one of the devices, all buttons are going through a resistor ladder into an analog pin where they are being read. The sketch then descides which button is being pushed depending on the voltage reading.
On the other device, I have used all IO's on the mcp in order to give each button its own IO. Both setups work fine, and there are no difference in the amount of distortion on the two devices, so I don't think this has anything to say.
I ordered 4 wave shields to have enough, and so far I've built 3 of them. Now I just tested the one that I haven't used for these devices yet, and you know what: it's not distorting!!!
Phew.. so it's not just the shield itself, but something with my application obviously. I apologize for my straight forward frustration-posts earlier.
So, somewhere something in my hardware (or code?) is going wrong.
My code is 714 lines long. Could it be that it's too much for the arduino to handle? I won't guess so myself, but I'm not sure. I've attached it for the device that uses resistor ladder.
I also tried powering the arduino with usb instead of through the voltage regulator, and this didn't improve anything. My soldering is pretty neat, and since it's happening on both devices, and wouldn't blame this as an issue.
Any ideas as to what I could do to troubleshoot this is very very appreciated.