First, why did you quote your own text?
Okay, to get it straight, you want to only switch on the output when you switch on s1, not matter s2. And only switch off the light when you switch off s2?
Because a user case you don't give is switching on s2 first...
I'm to lazy to read to code because it loops waaaaaayyyyyyy to long for what you want. Here is code that does what you want (if that's what I described). I use Bounce2 to keep the switch handling simple.
#include <Bounce2.h>
const byte OutputPin = 13; //calling it in1 is plain stupid
const byte SwitchPins[] = {5, 4}; //once you start numbering variables, use an array
Bounce switches[sizeof(SwitchPins)];
void setup()
{
//setup the switches
for(byte i = 0; i < sizeof(SwitchPins); i++){
switches[i].attach(SwitchPins[i], INPUT_PULLUP); //use INPUT if you have external pull up/down resistors
}
//setup the output
pinMode(OutputPin, OUTPUT);
}
void loop()
{
checkSwitches();
}
void checkSwitches()
{
for(byte i = 0; i < sizeof(SwitchPins); i++){
switches[i].update();
}
//I here assume pull up resistors (like with INPUT_PULLUP)
if(switches[0].fell()){
digitalWrite(OutputPin, HIGH);
}
if(switches[1].rose()){
digitalWrite(OutputPin, LOW);
}
}