In the cat graphing example in chapter 3 as published in the book, the comments say:

// if the sensor value is less than the threshold,
// and the previous value was greater, then the cat
// just left the mat
if (prevSensorValue >= threshold) {
   catOnMat = false;
}

According to the second comment, the condition should be “greater,” but actual code is “greater or equal.”

The comment is right and the code should be as follows:

// if the sensor value is less than the threshold,
// and the previous value was greater, then the cat
// just left the mat
if (prevSensorValue > threshold) {
   catOnMat = false;
}

Thanks to Shigeru Kobayashi for catching this.

   
© 2012 Making Things Talk Suffusion theme by Sayontan Sinha