Pages: [1]   Go Down
Author Topic: Arduino Alarm system.  (Read 744 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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");
  }
   
}

« Last Edit: December 06, 2012, 01:25:02 pm by JochemHam » Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Indiana, US
Offline Offline
Full Member
***
Karma: 12
Posts: 204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

There are 10 types of people in the world, those that understand binary, and those that don't.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: