Thanks for making efforts . Really appreciate
a). I have again updated the code with comments to better understand each step .
UPS load switcher. - Wokwi Arduino and ESP32 Simulator
Think of all 3 LEDs as different relays which would later be used with suitable transistor to drive them with the Arduino.
b). Have tried the new code you shared but it still doesn't wait for 5 seconds. No matter how many times we press the slide switch { inputpin(7) HIGH/LOW } nothing should happen , the switch should stay at a position for atleast 5 seconds before any state change of any relay.I want the Arduino wait for 5 seconds after a power fail / restore event and if the condition is met then proceed for the next step. Something like that - Check if condition is still met 0.5 second after initially met
.