Vibration Sensor

From Microduino Wiki
Jump to: navigation, search


Vibration sensor---whose internal structure is like a metal ball that is fixed in a special spring as pole, around it is the other pole. When the vibration gets to an extent, the two poles are connected so as to judge the shock occurs. Vibration sensor outputs digital signal.


  • Electrical specification
  • Operation voltage: 5V
    • Input device
  • Tech parameters
    • Wide vibration detection range
    • Without direction limitation
    • 60,000,000 times of vibration insurance. (Special gold plating on the surface of the connection foot)
  • Size
    • Sensor size: 9.0mm*9.15mm
    • Board size: 20mm*20mm
    • 1.27mm-pitch 4PIN interface can be connected with the sensorhub.
  • Connection method
    • Pin description: GND, VCC, signal input and NC(empty).
    • Digital input



  • Other hardware equipment
    • A USB cable


  • Setup 1: Connect the Shake sensor's interface with the Hub's digital D6 port.
  • Setup 2: Stack the CoreUSB, Hub and Shake sensor together and then connect them to the computer with a USB cable.


  • Open Arduino IDE and copy the following code into IDE.
#define pushButton  6

int buttonState;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  buttonState = digitalRead(pushButton);//Read the input value of the Shake sensor. 
  // print out the state of the button:
  Serial.println(buttonState);  //Print the sensor value in the serial port. 
  delay(100);     //100ms delay 
  • Select the right board and COM port, compile and download.
  • Open the serial monitor.
  • The value of " buttonState " is 0 when there is no vibration or it is 1 when there exists vibration.

*Adopt "digitalRead(XX)" function to read vibration digital signal with two status of "0" and "1".


  • Burglar arm