Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Using the Vibration Switch Module KY-002 with Arduino

Contents

Introduction

In this tutorial, we will learn about the KY-002 module, how it works and we will build a simple project to detect vibration using the KY-002 module and an Arduino.

Vibration Switch Module KY-002

The KY-002 Module will be our main component for this tutorial. This module has a vibration switch mounted on the breakout board with a resistor. Figure 1 shows the module as seen in fritzing.

Figure 1: KY-002 Vibration Switch Module

Pinout

The KY-002 module has three pins.

Component PinDescription
(-)GND
middle+5V
SSignal

How The Vibration Switch Works

The KY-002 module incorporates a switch that is sensitive to shaking. It has a spring surrounded by a conductive material. When the module experiences shock or vibration, the spring flex and touches the surrounding conductive material.

Project - Arduino Shock Detector

After learning about the KY-002 module and how the vibration switch works, it is now time to build a project using the module. Our project will monitor if the module senses shock/vibration and will light-up the built-in LED of the Arduino Uno.

Components

For this project, we need the following components:

  • Arduino Uno board (1 pc.)
  • KY-002 Vibration Switch Module (1 pc.)
  • Jumper wires

Wiring Diagram

Figure 2: Connection Diagram

Figure 2 shows the connection between the Arduino Uno and the KY-002 Vibration Switch Module.

The KY-002 module pins are connected to the Arduino Uno board as follows:

Component PinArduino Uno board Pin
(-)GND
middle+5V
S8

The Code

Below is the Arduino sketch for our project. I have added comments to explain important parts of the code. Save the code as KY-002.ino and upload it to your Arduino board.

				
					// KY-002 Vibration Module Tutrorial
void setup() {
  pinMode(8, INPUT);    // KY-002 module is connected to pin 8
  pinMode(13, OUTPUT);  // set pin 13 to output which is also the built-in LED
}
void loop() {
  if(digitalRead(8) == HIGH) {  // module will make pin 8 HIGH if it detects shock/vibration
    digitalWrite(13, HIGH);     // swtich ON the built-in LED
  }
  else digitalWrite(13, LOW);   // switch off LED otherwise 
}
				
			

Project Test

Apply power to your Arduino Uno board. Shake the KY-002 module and observe the built-in LED. As you shake the module, the LED should blink giving a visual indication that the module senses vibration.

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top