Arduino and SW-420 Vibration Sensor

posted in: Arduino | 25

In this Arduino Tutorial SW-420 vibration sensor was used. It can detect vibrations from various sources.

Download # Arduino Code (*.ino file)


Upload Arduino code directly to your Microcontroller from website

If you want to integrate Arduino IDE into your website (as above) sign up here: codebender

Follow me:

25 Responses

  1. Hi, thousand thanks for your code! i tried several not working but this works so perfectly!
    Btw, I will need to interface with two sensor, I dont know how to change the code to measure for two, could you please help me please?

    Thank you so much in advance..Have a great day!


    • I’m glad it works. The code is not complicated at all in order to add additional sensor, try to sort it out by yourself.

      • may I know what am I measuring in the code? is it vibration amplitude or vibration time ?

      • tell me if measure 8 sensor output value ….???

  2. azriel

    how to use this with arduino uno

    • The same way as nano, just connect to a proper pins, which is also written in the code itself.

  3. Is that the measurement is a frequency?

  4. Souvik

    HI, I had a quick question, according to my understanding, this is a digital sensor, in the sense that, the output from it is going to be only 0 or 1 based on the set threshold, (which you set by turning the potentiometer screw on board). How come your measurement output is showing values greater than 1?

    • Correct. This is because pulseIn function was used.

    • pallavi

      Because it is not the value of input pin. if we print the value at input pin then and only then it will be in 0 or 1.

  5. nanik alviandari

    thankyou so much. it works on my Arduino Uno with SW-18051P NO Vibration Sensor Module Arduino 🙂

  6. can you please suggest me which vibration sensor to use on car window to detect any vibration on window for my project vehicle antitheft system and which will be integrated to arduino uno

  7. Hi, what if I want to put more than 1 vibration sensor, may I know how’s the coding may look like?

  8. i would like put 8 sensor and how can i control these through arduino and and every sensor output must be display at computer individually and plz tell me if it is possible .

  9. Saved me some frustation… A million Thanks.

  10. What is unit for measurement ?

  11. What does 1000 mean? Is it 1000mm, 1000um or something else

  12. Nice example. Just want to know can i remove red LED on the pcb board? I need to reduce power consumption since I’m running on battery.

  13. Mukesh

    what is the maximum amplitude of vibration and it would be grateful if the unit of measurement is known.

  14. lalit shendre

    hey admin can you help me to construct a code for my project ?
    sensing and supressing vibration of cantilever beam and displaying same on computer screen or DSO
    it consist of a cantilever beam A Sensor actuator pair an arduino

  15. What does 1000 mean?

Leave a Reply