[SOLVED] Piezo Sensor Output

I recently bought a Piezo component to be able to detect knocks on a surface. I've verified that the component works as an output device, as I used it to successfully generate a given tone (using the example here: http://arduino.cc/en/Tutorial/Tone). However, when attempting to use it as an input source, I get less than desirable results.

The piezo is connected to analog input A0 through a 1M? resistor. Here is a picture of how it's set up:

I've used code that simply loops and spits out the sensor reading (using analogRead(knockSensor)) per every iteration. The output does seem to change if I touch the Piezo sensor, but it doesn't seem to respond when I knock on the surface it's taped to. Additionally, if I tap it, the output either drops down to 0, or it continues rising up to 1023 long after I got away form it (it usually takes about 7 seconds to reach 1023 after tapping it). Why is this happening?

Also, did I post this in the correct section? If not, I'll delete it and post it where I should.

Bump..

try connecting one end to 3.3V and the other to A0 and see if that helps.

It will bias the device to around the level of 690 and you may be able to spot.

I tried to do something similar to this the other day using a speaker as a vibration detector but it wasnt very successfull

I wrote this code, but there just wasnt enought input amplitude for it to work reliably

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to


int sensorValue;

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(115200); 
}

void loop() 
{
  int maxVal=0;
  int minVal=1023;
  for (int i=0;i<250  ;i++)
  {
    // read the analog in value:
    sensorValue = analogRead(analogInPin);  
    maxVal=max(sensorValue,maxVal);
    minVal=min(sensorValue,minVal);
  }
  
  if (maxVal-minVal>4)
  {
    Serial.print("-------------------------------BUZZ ");
    Serial.println(maxVal-minVal);
  } 
  else
  {
    Serial.println("");//maxVal-minVal
  } 


}

Most people put the resistor in parallel with the piezo element, between the analog pin and ground. Also, the element has a polarity so you might try it both ways around. Here is a tutorial to try out http://www.arduino.cc/en/Tutorial/KnockSensor The voltage peak is very short lived, so you may have to sample rapidly to catch it.

Oh..placing the resistor in parallel works. This is the current, working, setup: My bad. Thank you for your help!