Logic loop for taking pictures.