Arduino Tutorials – Lesson 35 – Vibration Sensor on Arduino UNO

Creating Vibration Sensor program using Arduino UNO

Required Components

  1. Arduino Uno Board _1 no
  2. Vibration Sensor _1 no
  3. USB Cable _1 no
  4. Connecting Wires _1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Arduino UNO 7th pin to the Vibration Sensor DO pin.
  3. Connect the Arduino UNO 5V, GND to the Vibration Sensor VCC, GND.
  4. The LED 13th pin is Default.
  5. Connect the ground connection respectively.
  6. Check the Arduino program.
  7. Check the circuit connections.
  8. Run the Arduino program.

Arduino Program

int vib_pin=7;
int led_pin=13;

void setup() 
{
  pinMode(vib_pin,INPUT);
  pinMode(led_pin,OUTPUT);
  Serial.begin(9600);
}

void loop() 
{
  int val;
  long measurement =vibration();
  delay(50);
  Serial.println(measurement);
  if (measurement > 50){
    digitalWrite(led_pin, HIGH);
  }
  else{
    digitalWrite(led_pin, LOW); 
  }
}
 
long vibration()
{
  long measurement=pulseIn (vib_pin, HIGH);  
  return measurement;
}

Usage

  1. Food & Beverage
  2. Water & Waste water
  3. Oil & Gas
  4. Automotive

Leave a Reply

Your email address will not be published. Required fields are marked *