Virtual latching relay

//z-parakeet inc.'s Fire Alarm Sketch
#include <LiquidCrystal.h>
// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4, d5, d6, d7 on pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int ledPin = 13; // choose the pin for the LED
int buzzerPin = 9; //buzzer/alertor
int inputPin = 8;               // choose the input pin (for a pushbutton)
int val = 0;            // variable for reading the pin status
int truPin = 7;
int Alarms = 6;
int sil = 0;
void setup() {

 pinMode(buzzerPin, OUTPUT);   //declare BUZZER or allertor as a output!
 pinMode(ledPin, OUTPUT);      // declare LED as output
 pinMode(inputPin, INPUT);  // declare pushbutton as input
 pinMode(truPin, OUTPUT);
 pinMode(Alarms, OUTPUT);
     digitalWrite(buzzerPin, HIGH);
     digitalWrite(ledPin, HIGH);
     digitalWrite(truPin, HIGH);
       lcd.print("System Loading");
       lcd.print(".");
       delay(1000);
       lcd.print("..");
               delay(1000);
       lcd.print("...");
   delay(1000);
     lcd.print("System Stats: Standby");
   digitalWrite(buzzerPin, LOW);
   digitalWrite(ledPin, LOW);
   digitalWrite(truPin, LOW);
delay(2000);
}


 

void loop(){
 val = digitalRead(inputPin);  // read input value
 delay(0); //used to be a delay, but changed cuz of my update!
 if (val == HIGH) {      // check if the input is HIGH
 lcd.print("ALERT! TROUBLE OR FIRE");
   digitalWrite(truPin, HIGH);
   digitalWrite(ledPin, HIGH);  // turn LED ON
   delay(50);
   digitalWrite(ledPin, LOW);
   delay(50);
   digitalWrite(buzzerPin, HIGH);
     lcd.print("CHECK PULL STATIONS");
   delay(50);
   lcd.print("OR TEST SWITCH");
   digitalWrite(buzzerPin, LOW);
   delay(50);
   digitalWrite(Alarms, HIGH);
 } else {
     lcd.print("Standby.");
   digitalWrite(ledPin, LOW); // turn LED OFF
   digitalWrite(truPin, LOW);
   digitalWrite(Alarms, LOW);
   
 } 
}

ive been posting that alot, but i need to know how to have it once the button is activated, it wont stop till i press the reset button on the arduino duemilinove.

Is your button connected using a resistor? The tutorial here explains about pull-up and pull down resistors: http://www.arduino.cc/en/Tutorial/Button

You can also use internal pull-up resistors; this tutorial explains more about digital pins and how to enable the internal pull-up resistors: http://www.arduino.cc/en/Tutorial/DigitalPins

What you're looking for it called a "state machine" in technical circles. Basically, the actions you perform and the inputs you watch are dependent on some "state" variable that you save: "If the relay is off, look for the ON button. If the relay is ON, look for the off button.

#define RELAY_ON 1
#define RELAY_OFF 0

byte state = RELAY_OFF;

void loop()
{
 if (state == RELAY_OFF) {
   if (digitalRead(inputPin)) {
     alarm_on();
     state = RELAY_ON;
   }
 } else if (state == RELAY_ON) {
   if (digitialRead(resetPin)) {
     alarm_off();
     state = RELAY_OFF;
    }
  }
}

As you get more states, you have a good excuse to learn about the "case" statement.

huh >:D

i am still kinda new to arduino, but i dont understand...

Change:

void loop(){
val = digitalRead(inputPin); // read input value

To:

void loop(){
if (!val)
val = digitalRead(inputPin); // read input value

westfw: he said the reset button on the board. His state machine is a one-way gate from “off until input” to “on forever.” Not what I would do, but…