everybody knows this song🙂
Today I decided to experiment a little bit with pizzo sensors and DuinoMite. We used to produce car alarm systems 20 years ago and I have plenty of piezzo disks in my bin, they are with 20 mm diameter and we used them to produce shock sensors which detect impact on car’s body.
I carefully soldered 1Mohm resistor in parallel with the piezzo disk and with two wires connected between GND and PIN.1 on DuinoMite-Mini.
Then used pvc tape to attach to my desktop, so the sensor will vibrate with every desktop vibration. Piezzo sensors generate electricity when subject to physical force, as usual Wiki is good reference if you want to learn more about them http://en.wikipedia.org/wiki/Piezoelectric_sensor
generally you should think for the Piezzo sensor as capacitor, this is the reason to add the 1Mohm resistor in parallel to discharge the Piezzo once it generates the voltage when vibrating.
I looked at the generated signal with oscilloscope and the amplitude of the generated voltage was about 0.05V with light knocks near it, up to 3-5V when hit directly on the sensor. The 1Mohm resistor discharge it for about 25-40 milli seconds.
Now I’m ready to read it and wrote this small code:
10 SETPIN 1,1 ‘setup PIN(1) as analog input
20 DO WHILE PIN(1) < 0.01: LOOP ‘wait until you detect voltage above 0.01V
30 PRINT “KNOCK “;
40 PAUSE 60 ‘wait enough to discharge the piezzo
50 GOTO 20 ‘endless loop
run the code and the result was as expected, the sensor was detecting every of my knocks around it.
here is video demonstrating how DuinoMite detects knocks http://youtu.be/tdVYdd6sCVg
Now this is good ground for other fun projects like – electric door which you open by knocking with secret knock sequence like on this video: http://www.youtube.com/watch?v=zE5PGeh2K9k, or stairs which light on when you step on them like on this video: http://www.youtube.com/watch?v=aYH5J43DapU