Just to add that this is actually preferable to the LDR solution as it uses amazingly little power when idle.
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Just to add that this is actually preferable to the LDR solution as it uses amazingly little power when idle.