How to build a ARDUINO controlled window or door alarm

This tutorial will show you how to build a window or door alarm using a ARDUINO board and photo interrupters or magnetic sensors…

Click on video below for full tutorial…

 

Parts List:

ARDUIUNO board

speaker

photo interrupter or magnetic sensor

 

SCHEMATIC:

 

ARDUINO Code:

#define s1 2
int v1;
#define spk 9
void setup() {
Serial.begin(9600);
pinMode(s1, INPUT);
pinMode(spk, OUTPUT);
}

void loop() {
v1 = digitalRead(s1);
if (v1 == HIGH)
{
tone(spk, 500, 250);
delay(250);
tone(spk, 1000, 250);
delay(250);
}

}