After researching around, I found another useful tutorial on piezo elements at the Arduino website (Arduino Knock Tutorial). Since our class just learned how to make LEDs blink using the Arduino (Thanks Todd!), I modified the code just a little bit to incorporate both the piezo knock and LED blinking light.
In the first part of this circuit, I attached my bare piezo disc (along with a 1 MΩ resistor to limit the voltage and current drops) to the analog input pin A0 and ground. After, I wired up a 220Ω resistor from digital pin 13, along with a pink LED to ground.
Sadly, this third part was the most frustrating thing I’ve dealt with all day. Apparently, when I tried to type “sensorReading = analogRead(knockSensor),” I needed to watch what my pinky finger actually pressed on the keyboard… – is not the same as = and it took me nearly 20 minutes to catch that error!
After that tiny mishap, I verified the code and uploaded it to my Arduino. Here is a screenshot of the code:
At first, I set the threshold to 100 and I realized that the piezo wasn’t as sensitive, as seen here with my kitten :3
So, I decided to change the threshold to 75 and it was successful.