Hello,
My project consists of a lead running from 5V to a variable resistor (in this case, a velostat-taped penny). I have another lead running from analog in with the other end taped to a penny. When the two pennies touch, they act as a switch, and a sound is then emitted from a piezo speaker connected to PWM pin 9.
This works well, but I want volume control. My idea is to make the sound louder as the two pennies were conducting more electricity (hence the velostat to get a wider range of values when the pennies are pressed together). Basically, it's acting as a pressure sensor. However, currently it's giving all, nothing, or static-ey sound.
My Serial monitor is detecting different currents, but I'm not sure how to translate these readings to volume. Any ideas? Thanks so much!
I don't think you can use this to directly change the volume (that needs a voltage/current change) ( I'm sure some one will correct me) but you could change the tone according to the input.
Code to play tune (according to my notes):
https://web.archive.org/web/20140117015124/http://ardx.org/src/circ/CIRC06-code.txt
Mark
Interesting. My Googling has yielded similar results: volume on piezo can only be changed by current change to the speaker (though PLEASE correct me if there is any other way).
I guess my follow up question would be, is there any way to restrict current flow through software?
So I could say,
if (current flow through penny circuit does not reach threshold) {
restrict current to speaker
}
That kind of thing? Or would it forcefully require a (physical) variable resistor of its own?