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

Hall Magnetic Sensor Module

Hall Magnetic Sensor Module

Im Folgenden finden Sie den entsprechenden Code zu sehen:Ein Beispiel für ein Projekt für die K..

2.36€ Ex Tax: 1.95€

Hall Magnetic Sensor Module (analog)

Hall Magnetic Sensor Module (analog)

Below you can see the corresponding code:An example of a project for the KY-035/* Author: Danny van..

2.36€ Ex Tax: 1.95€

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€

Touch Sensor Module

Touch Sensor Module

Im Folgenden finden Sie den entsprechenden Code zu sehen: Ein Beispiel für ein Projekt für die KY-0..

2.36€ Ex Tax: 1.95€