How It Works
A vibration switch is a very small cylindrical sensor that has a stiff piece of metal surrounded by a spring. The spring normally doesn't touch the stiff leg, so the circuit is open. When it is moved, the spring will vibrate a bit, touching the stiff leg, and closing the circuit. You can see the copper leg with its coiled spring surrounding the silver colored leg in this cutaway photograph.
By connecting one leg to analog pin A0 and the other to GND, we can code the Gemma M0 so that it monitors the analog value of the A0 input pin — when the spring vibrates it will send the analog pin to ground, and so the analog voltage value will decrease. When the value goes below a certain threshold, the code will send a pulse width modulated (PWM) tone signal to the piezo buzzer on D0 to make it sound the alarm.
Assembly
The Gemma M0 can't make any sounds on it's own, so let's connect the piezo buzzer to it so we can hear it!
Bending Legs
We'll use the two M3 screws and nuts to connect the buzzer's legs to the D0 and GND pads of the Gemma M0.
Use pliers (or your fingers) to bend the legs down, carefully, making sure not to break them off.
While the legs will bend easily to their new position, trying to move them back to their original position may be more stress than they can take.
Each leg can fit nicely into a small groove molded into the plastic case.
Make Feet
Use the pliers or the screws themselves to form small hook-like feet at the end of each leg, as shown here, so they will connect to D0 and GND. (You can check the other side of the board to see the pad names on the silkscreen.)
It doesn’t matter which leg of the buzzer goes to which pad, it is not polarized.
Thread the nuts on and tighten them, being careful that the legs don't touch any copper pads on the board other than their respective pin assignments.
We’ll connect the vibration switch to A0 with the thicker, silver colored leg. Use a screw and nut to connect it to the Gemma M0 as shown.
You'll use an extra nut to connect the thin wire of the vibration sensor to the same GND screw that's being used for the piezo buzzer.
That’s all there is to it — next we’ll program it!
Text editor powered by tinymce.