Hardware Reference
In-Depth Information
Continued from previous page.
PImage thisFrame = get();
thisFrame.save(fileName);
postPicture();
lastPictureTime = currentTime;
}
// if the last reading was less than the threshold,
// then the cat just got on the mat.
if (prevSensorValue <= threshold) {
println("cat on mat");
sendMail();
}
}
else {
// 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) {
println("cat not on mat");
}
}
// save the current value for the next time:
prevSensorValue = sensorValue;
}
}
8
The sendMail() method checks to
see whether enough time has passed
since the last mail before it sends.
Then it calls the cat-mail.php script
using the loadStrings() function to
make an HTTP GET request.
void sendMail() {
// how long has passed since the last mail:
int timeDifference = currentTime - lastMailTime;
if ( timeDifference > mailInterval) {
String[] mailScript = loadStrings(mailUrl);
println("results from mail script:");
println(mailScript);
// save the current minute for next time:
lastMailTime = currentTime;
}
}
 
Search WWH ::




Custom Search