How to Use a Vibration Sensor (shake Switch) - Arduino Tutorial
by codebender_cc in Circuits > Arduino
87073 Views, 46 Favorites, 0 Comments
How to Use a Vibration Sensor (shake Switch) - Arduino Tutorial
![vibration-sensor-switch-218015d.jpg](/proxy/?url=https://content.instructables.com/FAM/5QGZ/IFK0Z0A4/FAM5QGZIFK0Z0A4.jpg&filename=vibration-sensor-switch-218015d.jpg)
In this tutorial we will use one vibration sensor (or shake switch) to make a beep sound from a buzzer while we shake our breadboard.
Watch a demonstration video:
Let's get started!
What You Will Need
![a.png](/proxy/?url=https://content.instructables.com/FN8/YA0D/IFK0Z0CR/FN8YA0DIFK0Z0CR.png&filename=a.png)
For this tutorial you will need:
- Arduino uno
- Breadboard (or breadboard shield)
- Buzzer
- Vibration/shake sensor
The Circuit
![a.png](/proxy/?url=https://content.instructables.com/F6T/T756/IFK0Z0H7/F6TT756IFK0Z0H7.png&filename=a.png)
The connections are pretty easy, see the above image with the breadboard circuit schematic.
- Connect one pin of vibration sensor to Arduino Analog pin A0 and the other to 5V pin.
- Now connect the buzzer, one pin to Arduino pin 8 and the other to GND.
The Code
![IMG_20151010_125141.jpg](/proxy/?url=https://content.instructables.com/FWO/WGLF/IFK0Z0KK/FWOWGLFIFK0Z0KK.jpg&filename=IMG_20151010_125141.jpg)
Here's the code, embedded using Codebender!
Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino with this sketch.
You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code.
For example, try to change delay time or 1022 analog value see how it changes the program.
Press connect button below to start serial communication and start shaking the sensor.
Well Done!
You have successfully completed one more Arduino "How to" tutorial and you learned how to use a vibration/shake sensor!
I hope you liked this, let me know in the comments.
There will be more of them, so make sure to click Follow button!
Find more useful Arduino Tutorials here