sushanth2008
Published

Shock sensor

When something shakes this sensor it alert you

BeginnerFull instructions provided250
Shock sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Amazon Web Services shock sesnors
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

circuit

how to join the wires

Code

coding

Arduino
upload this code to make it working
//Simple way to use a shock sensor

int SHK_PIN = 3; //Pin for the shock sensor

int shk; //Variable to store the shk reading

//Setup the Arduino
void setup() 
{
  Serial.begin(9600); //Start the serial connection to the computer
  pinMode(SHK_PIN, INPUT); //Make the pin you used an input on the Arduino
}

//This code will run infinitely
void loop() 
{

  delay(1); //Delay 1mS to slow to 1000 readings per second
  if(digitalRead(SHK_PIN) == LOW) //Read the shock sensor
  {
    Serial.println("Shock Detected"); //Print out that we have been shaken
    Serial.println("Resetting...");
    delay(500); //Wait half a second before reading again
  }
  
}

Credits

sushanth2008

sushanth2008

2 projects • 2 followers

Comments

Add projectSign up / Login