Professional Documents
Culture Documents
Summary
We will use the vibration sensor to control the blinking of a LED light in this project.
Materials
Arduino Uno x 1
Vibration sensor SW-520D x 1
5mm LED light x 1
220 Ohm resistor x 2
Breadboard x 1
DuPont wires
Production Description
The SW-520D is a ball type tilt vibration sensor with a unidirectional trigger switch. The
switch is made of metal. The electrical characteristics are similar to the mercury switch, but
it's more safe and environmentally friendly than a mercury switch and it has the same
characteristics of unidirectional conduction when the device is shaken.
The base state for the switch is Off when its angle is below 15 degrees. Above this angle the
switch turns On. When shaken the switch will turn on and off rapidly, or On continuously.
When there is no shaking the device should be orientated such that it reads Off. If the device
is positioned at an angle of greater than 15 degrees it is more difficult to trigger by shaking.
The switch is suitable for triggering a small current, it is NOT suitable for a power switch;
These Ball switches are widely used due to their small size and light weight in devices such as
digital photo frames, rotating screens, cell phone gravity sensors ,anti-theft devices and
intelligent systems.
Specification
Product Dimensions
Project Design
The vibration sensor detects the vibration and generates a signal. The project combines the
vibration sensor with a LED. The LED lights up when the sensor detects the object vibration.
The LED turns off when the vibration stops. This experiment uses the external interrupt
function.
Wiring Diagram
Note: The vibration switch requires a pull-down resistor and the LED requires a current-limiting
resistor.
Sample code:
When writing an interrupt function, you need to remember the following three points:
1 - When we write the interrupt function, the function can not contain parameters and return
values. In other words, if there is no return value of the function.
2 - Do not use the delay () and millis () functions in interrupt functions because the interrupts
will not be picked up.
3 - Do not read the serial port interrupt function, the serial port received data may be lost.