I am new to programming with Python and the Raspberry Pi, and for my first project i wanted to play the official "Push button stop motion" code from the official raspberry pi camera guide (https://projects.raspberrypi.org/en/projects/push-button-stop-motion)
I wired up the button sucessfully and didn’t change one thing in the code + downloaded and installed the picamera. The button works fine and takes pictures, but it only saves the last taken picture on the desktop. I tried adding an ongoing "i" but it doesn’t seem to work, can anybody help?
from datetime import datetime from gpiozero import Button import picamera import time b=Button(2) pc=picamera.PiCamera() running = True timestamp=datetime.now() def picture(): pc.capture('pic'+str(timestamp)+'.jpg') pc.start_preview() b.when_pressed=picture try: while running: print('Active') time.sleep(1) except KeyboardInterrupt: pc.stop_preview() running = False