Programming an automated fire extinguisher.

Oh crap. Your right. :astonished:

How do i separate them?
How do i change from buttons to relays?

Thanks for telling me all of this, i didnt even see it...

Relay 1 has to be connected to detector 1. And Relay 2 has to be to detector 2.
So that it does not sprinkle the wrong area.:wink:

Can i put in if/else detector 1 HIGH or something?
Any geniuses out there? :slight_smile:

Does this work?

 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;       

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

   // check if the pushbutton is pressed.
   // if it is, the buttonState is HIGH:
   if (buttonState == HIGH) {     
     // turn relays on:    
     digitalWrite(ledPin, LOW);  
   } 
   else {
     // turn relays off:
     digitalWrite(ledPin, HIGH); 
   }
   
   // check if the pushbutton is pressed.
   // if it is, the buttonState is HIGH:
   if (button2State == HIGH) {     
     // turn relays on:    
     digitalWrite(ledPin2, LOW);  
   } 
   else {
     // turn relays off:
     digitalWrite(ledPin2, HIGH); 
   }
}