PIR sense the movement of a warm body. It analyzed the pattern off environment to determined if there is changes in temperature. It detection angle 140 and 5m detection area.
When PIR detect motion, output pin will be high. This put a current into input on GPIO2 at a moment. MCU will detect the signal and set the sensor S0 variable to=1. If S0=1 , S1++. So if S1=1 L1 is on. Second time motion will put the lamp into bright mode where L1 L2 L3 L4 all light on. After 3 Motion the S0 reset to 0 and all the led set off.
The PIR detection angle has been narrow using piece of paper with small hole opening there.