###Nature_Box - created by TeCoEd###

import time
import picamera
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
PIR = 7
GPIO.setup(PIR, GPIO.IN)
global File_Number
File_Number = 1

def Nature_selfie(): ###Takes a picture of the wee Beastie###
    global File_Number 
    with picamera.PiCamera() as camera:
            #camera.start_preview()
            time.sleep(0.5)
            camera.capture("Nature" + str(File_Number) + ".jpg")
            File_Number = File_Number + 1

def Motion_Sensing(PIR): ###Response to movement###
    print "We see you"
    Nature_selfie()
            
###Code to respond to a movement of the wee Beastie###            
print "Ready to find you"
time.sleep(2)


try:
    GPIO.add_event_detect(PIR, GPIO.RISING, callback=Motion_Sensing)
    while 1:
        time.sleep(100)
except KeyboardInterrupt:
    print "Quit"
    GPIO.cleanup()




