Okay, but why this part
Raghavendra431:
Now s2 is in off condition, if i toggle s2 to on state and then to off state light should off.
[/quote]
Why toggle it twice?
If you skip the toggle twice part (which sounds way easier to use) but just change the output state every time a switch changes (for example s1: on => out:on, s2:on => out:off, s1:off => out:on) it's also very easy.
```
**#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++){
if(switches[i].update()){
digitalToggle(OutputPin);
}
}
}
void inline digitalToggle(int pin){
digitalWrite(pin, !digitalRead(pin));
}**
```