However when I serial print the Analog reading from the piezo disc, it is not stable. The value is constantly rising and rising even when I'm not touching it. When I hit it, it spikes to 1023 then goes to 0, then after a second it starts climbing again.
I have it taped to the desk. When I take away the tape and let the disc "float", the rate at which the value increases is even faster.
I've tried connecting the module to 3.3V and it slowed down the increase but it's still happening. I've also tried disconnecting the + all together but the problem persists, albeit slower.
Have tried searching online and can't find anything surprisingly because this seems like a very basic problem
const int piezoPin = A15;
void setup() {
pinMode(piezoPin, INPUT);
Serial.begin(9600);
}
void loop() {
int value = analogRead(piezoPin);
Serial.println(value);
}
With NO schematic, the problem is hard to determine. But, do you have a high value resistor directly ACROSS the piezo to discharge the voltage being produced?
When I made piezo disks (bare disks, cheap in bulk) into buttons my #1 concern was to burn a pin on piezo voltage.
You can wire a piezo to 2 opto-isolaters so press triggers one and release triggers the other and no pull-down on those wires. The pins are always reading, every time about 50k reads per second --- AVR digital pin drains 1 microamp per read.
Smack, the pin goes high and count the reads till it's low. A soft touch might read 30 and a full strike with a screwdriver handle read over 3000. The scale is ignored, the numbers are only roughly proportional, an about how hard indicator.
One thing I learned, diodes flatten piezo spikes. Leds and BJT's are diodes.