Piezo sensor problem.

Hallo, I have made a simple setup with an Arduino UNO, where a Piezo sensor and a 1M resistance are in parallel and are connected to GND and A0.
Then I made this simple code to see the analog input:

int knockSensor = A0;

void setup() {
  pinMode(13, OUTPUT);     
  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(knockSensor));
  }

I thought that my output in the serial monitor would lay steady and jump then the piezo was tapped at. But instead it just looks like this:
0
0
0
0
70
84
0
0
0
8
91
69
0
0
0
26
102
0
0
0
2
80
78
0
0
0
16
106
And that is when you don't touch the piezo. The numbers jump then I tap the piezo directly, but not when I tap around it. I am quite new to this, so I hope someone could help me out :slight_smile:

//Mobben

A 1M resistor is rather high and so the analogue input 'floats' picking up random interference. That's what you are seeing.
Try reducing it to 100K or lower.