How to Use a Vibration Sensor (shake Switch) - Arduino Tutorial

About: Arduino Tutorials by Codebender.cc Team

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!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard (or breadboard shield)
  • Buzzer
  • Vibration/shake sensor

Step 2: The Circuit

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.

Step 3: The Code

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.

Step 4: 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

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    12 Discussions

    None
    Byeboer

    6 months ago

    Hi every one, I just came across this cool switch as I'm in search for a way to sense seeds/fertilizer in my planter tubes. It looks like this could work, but I would need the buzzer to go when the switch is passive, since I want to be alerted when there is no movement inside of the tubes. How would one achieve this? Arduino is new to me, but I imagine a change in the code would do the job??

    None
    cybergenesis

    Question 8 months ago on Step 3

    Can the sensor be connected to wake up pin and be used to wake up arduino from sleep? Great tutorial. Thanks

    None
    Marioellis

    1 year ago

    Hi, if i wanted to control a 12 V circuit with this sensor so that it stops current flow to the circuit when it vibrates above a certain magnitude and res-ends current after a 2 second delay,how would i achieve this?

    None
    jeanniel1

    1 year ago

    I have a medium vibration sensor, and it just shows 431 at first than gradually drops to 360s and stays there without changing even though I'm shaking the thing like mad, or not touching it at all. Doesn't seem to change from this reading. I've checked and changed out connections to make sure I didn't miss anything.

    Does it make a difference which is positive for the vibration sensor?

    IMG_9477.JPG
    1 reply
    None
    jeanniel1jeanniel1

    Reply 1 year ago

    OK, I checked the serial plotter and it shows when the sensor detects movement - it's very sudden and sensitive. Looks seismic!

    vibratrion sensor serial graph.PNG
    None
    g7lfc

    2 years ago

    Any idea where you can purchase the vibration sensor in the UK please?

    Thanks.
    Derek

    3 replies
    None
    ntscg7lfc

    Reply 1 year ago

    how many you need Derek? I will send it to you from my country....

    None
    g7lfcntsc

    Reply 1 year ago

    Twelve for a project at our Code Club.

    None
    ntscg7lfc

    Reply 1 year ago

    Kindly send me your details for correspondence.

    None
    agent oo7

    1 year ago

    Is the buzzer active or passive?

    None
    rafaelnfs

    3 years ago

    I boutgh module but only show me around values 417 or 420 max.

    Great Tutorial! Shake Sensors are really useful for a lot of projects.