I'm trying to creature an instrument out of a few boards I have. The plan is to have piezo sensors wait for a hit, then be read by a digital pin, then execute code based on what piezo sensor was hit.
I know how to make a note play, but I don't know how to read a signal from a piezo that's between 3V and 5V. I'm not worried about velocity measurements, I just want there to be a hit, register the hit through arduino, then relay the pin number to a track number.
I read that pin change interrupts can read a signal instantly.
Below is some example code for my audio output board that plays audio files. This specific bit of code is for "notes" on an instrument.
wTrig.masterGain(-8); // Lower main volume wTrig.trackPlayPoly(6); // Play first note delay(1000); wTrig.trackPlayPoly(7); // Play second note delay(1000); wTrig.trackPlayPoly(8); // Play third note delay(1000); wTrig.trackFade(6, -50, 5000, 1); // Fade Track 6 to -50dB and stop wTrig.trackFade(7, -50, 5000, 1); // Fade Track 7 to -50dB and stop wTrig.trackFade(8, -50, 5000, 1); // Fade Track 8 to -50dB and stop
I don't have experience with code, but this is how I think activating a note would work:
wTrig.trackPlayPoly(pin number) delay(100); wTrig.trackFade(pin number, -50, 5000, 1);
As far as limiting voltage, don't I just need to put some resistors in circuit with the piezo sensors?
In psuedo-code, this is what I want to make happen:
Listen for signal from any pin Store that pin number as a variable wTrig.trackPlayPoly(pin number) delay(100); wTrig.trackFade(pin number, -50, 5000, 1);