I'm a total newbie taking a coding class in High School. I have been trying to get a portable PiCamera up and running, but I have encountered some bugs, that I do not know how to fix. Here is the code:
from gpiozero import Buttonfrom gpiozero import Button from gpiozero import LED from picamera import PiCamera from datetime import datetime from time import sleep right_button = Button(17) #GPIO17 --- pin 11 light = LED(23) #GPIO14 --- pin 16 camera = PiCamera() light.on() def capture(): light.off() stamp = datetime.now().isoformat() camera.capture('/home/pi/%s.jpg' % stamp) sleep(1) light.on() def loop(): While True: right_button.when_pressed = capture() try: loop() except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed. destroy()
I have currently 2 problems with running this code on my Raspberry Pi Zero. The first is that the LED does not light up, despite my efforts to plug in the ends correctly. The second is that once I press the button, the camera keeps taking pictures in an infinite loop onto the folder, until I kill the process. I can provide a picture if needed.
Anyone got any suggestions or tips? If I'm making any really dumb mistakes, I'm really sorry.