initial commit
fix race condition

 the code was based on the assumption of a floating input pin, which required
this race conditioned "fix". All good and reliable now.
Merge remote-tracking branch 'github/master'