চুম্বকীয় দরজার গার্ড — রিড সুইচ আর স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.
সার্কিট ডায়াগ্রাম · Circuit diagram
যা যা লাগবে · Parts you need
- 1 × Arduino Uno R3 Arduino Uno
- 1 × Reed switch (magnet switch) রিড সুইচ (চুম্বক সুইচ)
- 1 × Push button চাপ-বাটন
- 1 × Buzzer (5 V) Buzzer (বাঁশি, 5 V)
- 1 × Resistor 330Ω Resistor
- 1 × LED (red) LED বাতি
- 9 × Jumper wires জাম্পার তার
তার লাগানো · 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
- এলপিজি লিক অটো-কাটঅফ — গ্যাস ধরলেই ভালভ বন্ধLPG leak auto-cutoff (gas detector closes the valve)
- অটোমেটিক পেট ফিডার — এক চাপে এক পোরশনAutomatic pet feeder (one button, one portion)
- সিও ভেন্টিলেটর — MQ-7 সেন্সরে এক্সহস্ট ফ্যান ঘোরেCO ventilator (MQ-7 spins the exhaust fan)
- বৃষ্টি সেন্সর অরশদ — দোকান ভিজে যাওয়ার আগেই নিজে বন্ধ হয়Rain-sensing awning (closes itself before the shop soaks)