Go Down

Topic: Using a Piezeo Element to read analog values (Read 795 times) previous topic - next topic


Jul 20, 2013, 02:35 am Last Edit: Jul 20, 2013, 02:50 am by iisfaq Reason: 1

I am using an UNO and a piezeo element connected directly between ground and A0

The additional wires (red + orange) are only being used to hold the very small Piezeo wires in place - nothing else.

My code is

Code: [Select]

int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
 // declare the ledPin as an OUTPUT:
 pinMode(ledPin, OUTPUT);  

void loop() {
 // read the value from the sensor:
 sensorValue = 1023-analogRead(sensorPin);    
 // turn the ledPin on


This runs full speed and generally returns 0 if nothing is going on. But if I touch/tap the piezeo element it changes values say jumps to 600 and then slowly reduces back to 0.

This reduction to 0 can take 30 seconds.

I would have expected a much quicker drop to 0

If I was using this to record audio (such as a rain drop or hail) I would need much quicker reduction to 0 since one strong hail stone would be only a few ms not 30 seconds.

Any ideas on what I need to ensure a quicker drop and why it is doing this?

Could there really be that much energy being released over 30 seconds?



Have you seen this?
No technical PMs.
The last thing you did is where you should start looking.


OK I have found that if I put a 1M resister between the Red + Black legs of the Piezieo element then I get good data.

Thanks for the info on the knock sensor - it helped but I found it on a youtube video and not on here.


I have also changed the loop to

Code: [Select]

void loop() {
 // read the value from the sensor:
 sensorValue = analogRead(sensorPin);  
if (sensorValue >= 5)  
 // turn the ledPin on

So I now have

A0 connected to 1 Leg of 1M resister and then connected to RED leg of Piezo
GND connected to other leg of 1M and then connected to BLACK leg of Piezo


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131