Errata
Page 92 (Spotted by Federico Arismendi - thanks!)
The line
I = pinIn.value()
should be
i = pinIn.value()
The text processor we use has a habit of automatically upper casing i to I !
It has also been pointed out that setting s to zero in the else part of the if is pointless as s can only be 0 or 1 and therefore the else is never executed. This assumes that there is no hardware error, memory glitch, race condition in some other part of the program or even a stray cosmic ray that flips a bit.
If s is neither 0 or 1 then setting it back to 0 seems reasonable.
Is this being over cautious - it depends on the application.