Turn on the motion detection of TTL camera:
cam.setMotionDetect(true);
Verify if the motion is activated:
Serial.print("Motion detection is "); if (cam.getMotionDetect()) Serial.println("ON"); else Serial.println("OFF"); }
What happens when motion is detected by the camera:
if (cam.motionDetected()) { Serial.println("Motion!"); cam.setMotionDetect(false);
If motion is detected, take the picture or display the message:
if (! cam.takePicture()) Serial.println("Failed to snap!"); else Serial.println("Picture taken!");