Skip to content

Instantly share code, notes, and snippets.

@varunmehta
Created May 9, 2018 18:28
Show Gist options
  • Save varunmehta/8e41fc1173d59efa180bc77126882c22 to your computer and use it in GitHub Desktop.
Save varunmehta/8e41fc1173d59efa180bc77126882c22 to your computer and use it in GitHub Desktop.
Pi to click pics every 5 seconds.
# Run the file on boot;
#
# nano /etc/crontab
# @reboot root /path/to/script.sh
#
from picamera import PiCamera
from time import sleep
import time
import os
# Purpose of this program is to keep clicking photos,
# till storage is full or the pi is unplugged.
camera = PiCamera()
FILE_PATH='/home/pi/poker'
# create dir first time
if not os.path.exists(FILE_PATH):
os.makedirs(FILE_PATH)
# initalize camera
camera.start_preview()
sleep(10)
# infinite loop to click pictures
while True:
file_name = int(round(time.time()))
camera.capture(FILE_PATH + '/' + file_name + '.jpg')
# click a picture every 5 seconds.
sleep(5)
camera.stop_preview()
@varunmehta
Copy link
Author

Moved as a resin.io project to https://github.com/varunmehta/intervalometer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment