Tekko BDSimSimulatorProjects

চুম্বকীয় দরজার গার্ড — রিড সুইচ আর সireন দিয়েMagnetic Door Guard with a Reed Switch

চুম্বক কাছে থাকলে রিড সুইচ চালু থাকে — দরজা বন্ধ। দরজা খুললে ছোট্ট সময় পাওয়া যায়, তার পরেও খোলা থাকলে সireন বেজে ওঠে; বাটন চেপে থামাতে হয়।

The reed switch conducts while the magnet is near — door closed. Open it and a short grace timer starts, long enough to walk in with your key; miss it and the siren latches until the button says stand down.

▶ ফ্রি চালিয়ে দেখো / Run it free Parts অর্ডার করো (WhatsApp)

সার্কিট ডায়াগ্রাম · Circuit diagram

Magnetic Door Guard with a Reed Switch circuit diagram — Arduino Uno R3, Reed switch (magnet switch), Push button, Buzzer (5 V), Resistor 330Ω, LED (red), Jumper wires

যা যা লাগবে · Parts you need

তার লাগানো · Wiring

Reed switch (magnet switch) 1→Arduino Uno R3 5V
Reed switch (magnet switch) 2→Arduino Uno R3 D2
Push button 1→Arduino Uno R3 D3
Push button 2→Arduino Uno R3 GND
Buzzer (5 V) +→Arduino Uno R3 D8
Buzzer (5 V) -→Arduino Uno R3 GND.3
Arduino Uno R3 D13→Resistor a
Resistor b→LED A
LED K→Arduino Uno R3 GND.3

Code (Arduino C++)

// Magnetic door guard: the reed switch sits on the frame, the magnet on the
// door. Magnet near (door closed) the switch conducts and D2 reads HIGH. Door
// open starts a short grace timer — long enough to walk in with the key —
// then the siren latches. The button acknowledges and rearms once the door
// is closed again. Same principle as the shop shutter alarm downstairs.
long openedAt = -10000;
bool siren = false;

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(3, INPUT_PULLUP);
  pinMode(8, OUTPUT); pinMode(13, OUTPUT);
}

void loop() {
  bool closed = digitalRead(2) == HIGH;         // magnet near
  bool ack = digitalRead(3) == LOW;
  if (closed) { openedAt = -10000; siren = false; }
  else {
    if (openedAt < 0) openedAt = millis();
    if (millis() - openedAt > 1500) siren = true;
  }
  if (ack && closed) siren = false;
  digitalWrite(8, siren ? HIGH : LOW);
  digitalWrite(13, siren ? HIGH : LOW);
  Serial.print("Door: "); Serial.print(closed ? "closed" : "OPEN");
  Serial.print(" | Guard: "); Serial.println(siren ? "SIREN" : "armed");
  delay(150);
}

আরো project · More projects