Files
ProjectIOT/pico_files/single_photo.py
2025-06-14 10:18:40 +02:00

26 lines
722 B
Python

# A single, simple photo
# Import required modules
from machine import Pin, SPI, reset
from camera import *
from time import sleep
spi = SPI(0,sck=Pin(18), miso=Pin(16), mosi=Pin(19), baudrate=8000000) # Pins for the Raspberry Pi Pico
cs = Pin(17, Pin.OUT)
# A manager to handling new photos being taken
filemanager = FileManager()
print(1)
# Create a "Camera" object with the SPI interface defined above
cam = Camera(spi, cs, debug_text_enabled=True) # Default resolution of 640x480
sleep(1)
print(2)
# Capture a photo - this only takes a moment
cam.capture_jpg()
print(3)
# To let any data settle
sleep(.1)
print(4)
# Save the photo into the onboard memory
cam.save_JPG(filemanager.new_jpg_filename('image'))
print(5)