Debug output in readSensor gave a referenced-before-assignment error on inputAsInteger. Changed it to print s.