SCoop + Ardublock

First two options are not optimal because event are detected after delays. The last two options are using SCoop Sleep instead of delay. The last two options are better than the first ones.

scoop00

scoop01

scoop02

scoop03

SCoop should be installed at Arduino IDE