Hello everyone,
Here I come again with another tiny but interesting project. The project is called ‘Door alarm circuit’. The circuit rings an alarm when somebody opens the door. This circuit is sometimes important to ensure your privacy. The circuit can be attached to any type of door. Even if you’re a villager, living in a hut, you can use this circuit to ensure your safety and security.
Materials needed
Arduino UNO R3 x 1
Hall effect sensor x 1
Buzzer x 1
9V battery x 1
9V Battery to DC jack connector x 1
Ring Magnet x 1
Jumper wires
Scotch tapes
What is hall effect ?:
When a current-carrying conductor is placed in a magnetic field, a potential difference is produced. This phenomenon is called the hall effect. The produced potential difference is called Hall voltage. If you want to study further about the Hall effect, here is a good article.
Working principle of the circuit:
The hall effect sensor and the ring magnet are very close to each other in normal condition. In this condition, the output of the sensor is HIGH. When the door is open, the hall effect sensor can no longer sense the magnet. Its output becomes LOW. The output pin of the sensor is connected to pin#2 of the Arduino. The Arduino understands the door has been opened. It triggers the buzzer. The buzzer makes a sound continuously as long as the door is open.
Connections:
Arduino | Hall effect sensor |
5V | + |
Gnd | - |
2 | D0 |
Arduino UNO | Buzer |
11 | + |
GND | - |
// constants won't change. They're used here to set pin numbers: const int sensorPin = 2; // the number of the sensor pin const int buzzerPin = 11; // the number of the buzzer pin // variables will change: int sensorState = 0; // variable for reading the sensorpin void setup() { // initialize the singnal pin as an output: pinMode(buzzerPin, OUTPUT); // initialize the sensor pin as an input: pinMode(sensorPin, INPUT_PULLUP); Serial.begin(9600); } void loop() { // read the state of the sensorpin: sensorState = digitalRead(sensorPin); // check if there is magnet in front of the hall sensor. If so, the buzzerpin is Low: Serial.println(sensorState); delay(100); if (sensorState == LOW) { // turn sensor off: digitalWrite(buzzerPin, HIGH); } else { // turn sensor on: digitalWrite(buzzerPin, LOW); } }