AVR-T32U4 Arduino Leonardo experiments with knock sensor and servo

Image

This is simple fun project which we build for couple of minutes with materials in the office.

What you need: AVR-T32U4 Arduino Leonardo clone, Breadboard-1 for AVR-T32U4, LiPo battery, some JumperWires, Knock sensor, MS-1.3-9 servo motor, some tape and empty carton box.

Tape the servo in the corner and put on it plastic arm which to rise the box lid, tape the knock sensor to the lid. Connect the servo to D9 and Knock sensor to A0 of AVR-32U4.

The code Knock.ino is on GitHub https://github.com/OLIMEX/DUINO/tree/master/AVR/KNOCK, as you can see it’s pretty simple, once on A0 is detected level above some threshold (you can experiment what this level is in your case as it depend on how you attach the knock sensor to the box) you move the servo motor up wait some time and move it back.

Watch the video in action: http://www.youtube.com/watch?v=HFmPvcbbiT4

Then one of our practicing students at Olimex decided to make code which will open the box only if you knock in some secret sequence of long and short knocks and the code is also on Github (please be gentle the code is crappy but written by enthusiast with no much experience).

The new video for the password knock is here: http://www.youtube.com/watch?v=3wsnxi5x2R0

DouniMite Project: Knock Knock Knocking on heavens door!

Image

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