Vibration Sensor
From Microduino Wiki
Revision as of 01:50, 6 November 2015 by 1304410487@qq.com (talk)
ContentsOutlineVibration 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.
Specification
DevelopmentEquipment
Preparation
Debugging
#define pushButton 6
int buttonState;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// 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.print("buttonState:");
Serial.println(buttonState); //Print the sensor value in the serial port.
delay(100); //100ms delay
}
*Adopt "digitalRead(XX)" function to read vibration digital signal with two status of "0" and "1". Application
Video |