Programming an automated fire extinguisher.

Hi there Peter, yeah. I have researched 0 pollutant (100% destilled water) and it is not dangerous against any high or low Amp circuits as long as it is misted in low quantities.
Thanks for the interest and read.

bubulindo:
You are missing this:

int button2State = 0;

You should try to compile the code before posting... :wink:

Silly me :wink:
I will add it now. Thanks for the help dude.
As you said, i dont have any buttons in my setup. And you are right. But will the programming f things up if i do have what i have programmed?

There is only 2 relays (2-relay module) and 2 smoke detectors hooked up to the I/O ports in their ICs. I dont see the problems yet, but as we all know. Problems happen.

Here is the new recompiled coding:

 const int buttonPin = 2;     // smokedetector 1
 const int buttonPin2 = 3;    // smokedetector 2
 const int ledPin =  10;      // relay1
 const int ledPin2 =  11;     // relay2

// variables will change:
int buttonState = 0;
int button2State = 0;

void setup() {
   // initialize relay 1 pin as an output:
   pinMode(ledPin, OUTPUT);      
   // initialize relay 2 pin as an output:
   pinMode(ledPin2, OUTPUT);    
   // initialize the smokedetector 1 pin as an input:
   pinMode(buttonPin, INPUT);     
   // initialize the smokedetector 2 pin as an input:
   pinMode(buttonPin2, INPUT);     
}

void loop(){
   // read the state of the pushbutton value:
   buttonState = digitalRead(buttonPin);
   button2State = digitalRead(buttonPin2);

   if (buttonState == HIGH) {     
     // turn relays on:    
     digitalWrite(ledPin, LOW);  
   } 
   else {
     // turn relays off:
     digitalWrite(ledPin, HIGH); 
   }
   
   if (button2State == HIGH) {     
     // turn relays on:    
     digitalWrite(ledPin2, LOW);  
   } 
   else {
     // turn relays off:
     digitalWrite(ledPin2, HIGH); 
   }
}

I have a problem, i found out the Smoke detectors bounce on the I/O pins. This is bad, which means the waterpumps/relays would turn off and on all the time (1000ms bounce). How can i debounce that factor? So when the detectors are HIGH they stay HIGH and do not stop all of a sudden. :frowning:
Help would REALLY be appreciated!

I cannot (most likely) use the Delay fuction. Am I right? Any other easy functions that can fix the job? Or do I need an advanced algorithm? lol
Maybe I could use a pullup resistor and capacitor combo? I have no idea, im lost here.