rpiloverbd
Published

Anti-theft alarm

I made an anti theft alarm system. It can be used in cycles to save those from stealing.

BeginnerProtip-60 minutes408
Anti-theft alarm

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Tilt Switch, 15 °
Tilt Switch, 15 °
×1
passive buzzer module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Tape, Double Sided
Tape, Double Sided

Story

Read more

Schematics

anti theft alarm

Code

anti theft alarm

Arduino
// constants won't change. They're used here to set pin numbers:
const int buzzer = 9;
const int sensorPin = 10;     // the number of the sensor pin
const int signalPin =  13;      // the number of the signal pin

// variables will change:
int tiltState = 0;         // variable for reading the sensorpin
void setup() {
  // initialize the singnal pin as an output:
  pinMode(signalPin, OUTPUT);
  // initialize the sensor pin as an input:
  pinMode(sensorPin, INPUT_PULLUP);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // read the state of the sensorpin:
  tiltState = digitalRead(sensorPin);

  // check if the there is water on the rain sensor. If it is, the signalpin is Low:
  Serial.println(tiltState);
  delay(100); 
  if(tiltState ==HIGH)
  {
    digitalWrite(signalPin,HIGH);
    tone(buzzer, 2000); // Send 2KHz sound signal...
  }

  else
  {
    digitalWrite(signalPin,LOW);
    noTone(buzzer); 
  }
}

Credits

rpiloverbd
2 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.