Made simple sketch for light to switch when sensor detects object. Ultrasonic sensor HC-SR04 is installed on door frame, when person enters it detects and gives pulse output which is used to set the flip flop and intern switch on the light.
Flip flop trigger input is used and change from 0 to 1 used to set the another Flip flop and change from 1 to 0 used for resetting flip flop.
Delays ( 2sec) and AND gate used to block multiple pulses generated. Also more Delay (0.5 sec)node used to reset the change in status due to additional pulse.
In the debug mode if Tweak pulse is connected to Flip flop trigger then the sketch works as expected but when connected to HC SR 04 the Flip flop goes in error mode. Tried to use NAND gate flip flop but that also goes in Error mode.
I am new to Arduino and XOD. Please suggest way out. Thanks you.