I’ve been looking around on this forum for a while now and haven’t been able to find a post similar to this and I hope I posted it in the correct place.
I have a problem with readings on a Piezo with which I really hope you could help me!
First a bit of backstory:
I’ve been working with Arduino since today and i’ve done some projects to see how sensors are hooked up and how to write a script so that you can print the values a sensor measures.
At the moment i’m trying a step further towards my end goal which is to make a sound absorbing panel that rotates with the sun but closes when there is too much noise nearby. I have it working that a panel follows the sun with a servo and 2 photoresistors. This script is attached so you guys can get a clearer picture of this all.
Now to the point:
I’ve started on the sound measuring part of the script in a different file so I can see if it correctly measures the intensity of the sound nearby. I want the panel to close when the intensity gets above a certain treshold.
To begin I copied the first script for a knock sensor here:
This was to see whether it would actually work and every now and then I got a knock and then at other times I wouldn’t so I added the Serial.print part to the code to see what was actually going on.
However there is a constant measurement of 14 and in the beginning there is no noise and then after a few seconds it starts to non stop print “Noise”. If I increase the treshold to 250 it still works the same and then at 300 it just doesn’t print anymore.
I’ve attached the file, just in case I missed something in there, and a photo of the setup as well, in case I hooked it up all wrong (which is more likely I think).
I’d like to get a reading between 0 and 1023 like with a photoresistor if possible so I can get an idea which treshold would be needed to reset the servo to 0. Then delay the script for the light sensors so the panels would remain closed for 3 seconds then read the sound again. if the sound is still above the treshold, it would remain closed for another 15 seconds.
I’d love it if you could help me with at least the readings of the sound sensor so I can work on this project further.
Many thanks in advance!
Knock.ino (562 Bytes)
Sun_follower_-_Sketch.ino (1.3 KB)