Hit Sensor Module

  • Hit/Shock Sensor Module
Below you can see the corresponding code:
An example project for the Shock Sensor

//Author: Danny van den Brande, arduinosensors.nl
//This is a example of what you can do with the shock sensor.
//I made a simple mailbox alert project.
//Offcourse this can be used to detect anything else that produces a shock.
int ShockSensor = 4;
int RedLed = 5;
int GreenLed = 6;
int Buzzer = 7;
int value = HIGH;
boolean Alarm = false;

unsigned long LatestKnockTime; 
int TriggerTime = 25; //You can change this if you want the alarm to trigger longer.

void setup ()
{
  Serial.begin(9600);  
  pinMode (ShockSensor, INPUT) ; //the sensor set to input
  pinMode (Buzzer, OUTPUT);
  pinMode (RedLed, OUTPUT);
  pinMode (GreenLed, OUTPUT);
}
void loop ()
{
  value = digitalRead (ShockSensor) ; // Reading value
  
  if (value == LOW) 
  {
  
    LatestKnockTime = millis(); // 
    if (!Alarm){
      Serial.println("Shock detected");// You can add a lcd and make it print on LCD
      digitalWrite (GreenLed, HIGH);
      digitalWrite (Buzzer, HIGH);
      delay(1000);
      digitalWrite (Buzzer, LOW);
      delay(1000);
      digitalWrite (Buzzer, HIGH);
      delay(1000);
      digitalWrite (Buzzer, LOW);
      delay(1000);
      digitalWrite (Buzzer, HIGH);
      delay(1000);
      digitalWrite (Buzzer, LOW);
      delay(1000);
      digitalWrite (Buzzer, HIGH);
      delay(1000);
      digitalWrite (Buzzer, LOW);
      delay(1000);
      Alarm = true;
    }
  }
  else
  {
    if( (millis()-LatestKnockTime) > TriggerTime  &&  Alarm){
      Serial.println("Nothing Detected");
      digitalWrite (Buzzer, LOW);
      Alarm = false;
    }
  }
}
Specifications
Working voltage: 3.3v-5v

Write a review

Please login or register to review

Hit/Shock Sensor Module

  • Webwinkel Keurmerk en klantebeoordelingen

  • 14 dagen bedenktijd 
  • Verzendkosten voor eigen rekening
  • Product Code: KY-031
  • Availability: 14
  • 2.36€

  • Ex Tax: 1.95€

Similar Products

Ultrasonic capteur Distance - HC SR04

Ultrasonic capteur Distance - HC SR04

Below you can see the corresponding code :An example of a project for Distance Sensor/* Author: Dan..

2.99€ Ex Tax: 2.47€

Sound Sensor Module Small

Sound Sensor Module Small

Below the corresponding code:Example code: Digital output.int Led = 13 ;// define LED Interfaceint b..

2.29€ Ex Tax: 1.89€

Key Switch Button Module

Key Switch Button Module

Below you can see the corresponding code: An example project for the KY-004//Hello world! This time..

2.49€ Ex Tax: 2.06€

7 Color LED Module

7 Color LED Module

Below the corresponding code:/ * BlinkTurns on an LED on for two second, then off for two second, r..

2.36€ Ex Tax: 1.95€