reading a sensor and using an if statement