Arduino Alarm system.

Hey Guys,

I am building an alarm system with arduino but my programming skills are not really good. My question is:

  • When my IR-sensor gives a HIGH to the arduino it has to trigger the alarm. The alarm has to stay on untill I press a reset button on my system.

I have no idea how to do this so can anyone help me out here?

This is my work so far..
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int sensorPin = 2; // the number of the pushbutton pin
const int speakerPin = 9; // the number of the LED pin
const int pitchPin = 0;
LiquidCrystal_I2C lcd(0x27,16,2);

void setup()
{
pinMode(sensorPin, INPUT);
}

void loop()
{
int val = digitalRead(sensorPin);

if (val == HIGH)
{
int frequentie = analogRead(pitchPin);
int frequency = map(frequentie, 0, 1023, 100,5000);
int duration = 250;
tone(speakerPin, frequency, duration);
delay(100);
lcd.init();
lcd.backlight();
lcd.print("ALARM");
}
else{
lcd.init();
lcd.backlight();
lcd.print("Online");
}

}

In pseudocode:

If IR is HIGH, set ALARM = 1.

If BUTTON is HIGH, set ALARM = 0.

If ALARM is 1, sound alarm.

Now write it as a program :slight_smile:

Hi Jochemham,

I'd start by reading the tutorials on this site and prototyping a few things.

First, learn to understand switches, which should be fairly easy.
Second, get a buzzer and learn to turn it on and off via a GPIO pin and a transistor,
Third, download some code for the IR sensor and get that to work the way you want.

Then start to put them together in an orderly manner to build-up your final system.

I made a similar alarm system with a PING))) sensor to let me know when my dog needed to go outside.

There are a lot of tutorials around on programming and simple electronics. You can't beat learning by doing! It sounds like an interesting project.

Try some things and come back when you get stumped. There is a lot of help here.

Pat.

patduino:
Hi Jochemham,

I'd start by reading the tutorials on this site and prototyping a few things.

First, learn to understand switches, which should be fairly easy.
Second, get a buzzer and learn to turn it on and off via a GPIO pin and a transistor,
Third, download some code for the IR sensor and get that to work the way you want.

Then start to put them together in an orderly manner to build-up your final system.

I made a similar alarm system with a PING))) sensor to let me know when my dog needed to go outside.

There are a lot of tutorials around on programming and simple electronics. You can't beat learning by doing! It sounds like an interesting project.

Try some things and come back when you get stumped. There is a lot of help here.

Pat.

I've allready been doing a few project with buttons and piezo speakers and I2C monitors so that clear but I can't find any information about how to make the program I described in my last post.