Ok, well, I was hoping to not have to resort to the forums on this one, but I think I'm going to have to.
Anyhow, my project is simple: I'm trying to detect a sound with a piezo buzzer, and turn a LED on and off whenever I clap (basically this, except with and LED and Arduino.)
So with that being said, here's where I am. I found the Arduino example for the Knock Sensor here. I used the small piezo buzzer that came with my Ultimate Microcontroller Pack which I got from Makezine. The buzzer itself looks like this:
Basically, the Arduino example seems to be highly underdeveloped, and it doesn't even say what the impedance of the resistor should be. I've used different resistors, starting high, and working my way lower, until I eventually ended up taking the resistor out of the equation entirely. That worked for a while, but now it's just reading "0" in the serial monitor again. I connect the negative side of the buzzer to "GND" and the positive side to analog 0. When I print the value of analog pin 0 into the serial monitor, it just reads 0 no matter what I do.
So in short, my question is: What am I doing wrong and why did it just stop working? The buzzer still works as a speaker, so I know my buzzer isn't faulty. The circuit is very simple like I said, the negative side of the buzzer goes to ground, and the positive side to analog 0.
Try connecting A0 to 5V to test the analog input and your software.
I've used different resistors, starting high, and working my way lower, until I eventually ended up taking the resistor out of the equation entirely.
It's weird that you're reading zero with no resistor. The input should be "floating" and picking-up noise and reading somewhat random values.
I'd start with a 10M resistor. If the readings are too strong, try a lower value.
The buzzer still works as a speaker, so I know my buzzer isn't faulty
Hopefully, it's NOT a "buzzer". A buzzer has built-in electronics to generate a sound when you connect it to DC voltage. A speaker/transducer only makes sound when you drive it with an AC signal.
: I'm trying to detect a sound with a piezo buzzer, and turn a LED on and off whenever I clap (basically this, except with and LED and Arduino.)
That's probably not going to work without a preamplifier. Try "flicking" or "clicking" the piezo with your fingernail to see if you are getting a signal.
It's probably more practical to get a [u]microphone board[/u] rather than building your own preamp.
DVDdoug:
It's probably more practical to get a [u]microphone board[/u] rather than building your own preamp.
Alright that's what I was afraid of. Thank you for your insight. I ordered a microphone with a preamp. If I have any more questions once I have it I'll post them here.