Hi,
I apologize if I have made a duplicate post, but I've been searching for something similar and couldn't find one. I am new to Arduino and electronics in general. I am trying to make a midi drum based on schematic and sketch I found here:
htp://www.youtube.com/watch?v=LW8UZjsuBS0
First I tested with a single piezo, connected to A0 on the Arduino. I use Serial_MIDI_Converter_V2D, loopMIDI and Battery 4 for sampling and it worked.
Mine needs only 8 inputs right now, so I used a single CD4051 chip to multiplex the inputs and modified the code accordingly. I built the circuit on a perfboard with only one piezo disc connected. But when I uploaded the sketch, all the notes are played on Battery, even though I didn't hit the piezo.
I wrote the sketch below to test the circuit, attached a single piezo on pin 1 of the CD4051:
int r0 = 0;
int r1 = 0;
int r2 = 0;
int multiplex[8];
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
Serial.begin(9600);
}
void loop()
{
for(int count=0; count <= 7; count++)
{
r2 = bitRead(count,0);
r1 = bitRead(count,1);
r0 = bitRead(count,2);
digitalWrite(2, r0);
digitalWrite(3, r1);
digitalWrite(4, r2);
multiplex[count] = analogRead(0);
Serial.println(multiplex[count]);
delay(2000);
}
Serial.println();
}
And the output I get on the serial monitor is attached below(without hitting the piezo disc). I also attached a picture of the schematic I found (modified based on mine).
Can anyone please help me with my mistakes.






