Skip to content

Add motion detect example #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions examples/vc0706_snapshot_motiondetect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPDX-FileCopyrightText: 2017 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import board
import busio
import adafruit_vc0706

# Create a serial connection for the VC0706 connection, speed is auto-detected.
uart = busio.UART(board.TX, board.RX)
# Setup VC0706 camera
vc0706 = adafruit_vc0706.VC0706(uart)

# Print the version string from the camera.
print("VC0706 version:")
print(vc0706.version)

# Set the baud rate to 115200 for fastest transfer (its the max speed)
vc0706.baudrate = 115200

# Set the image size.
vc0706.image_size = adafruit_vc0706.IMAGE_SIZE_160x120 # Or set IMAGE_SIZE_320x240 or

# Note you can also read the property and compare against those values to
# see the current size:
size = vc0706.image_size
if size == adafruit_vc0706.IMAGE_SIZE_640x480:
print("Using 640x480 size image.")
elif size == adafruit_vc0706.IMAGE_SIZE_320x240:
print("Using 320x240 size image.")
elif size == adafruit_vc0706.IMAGE_SIZE_160x120:
print("Using 160x120 size image.")

# Turn on motion detection
vc0706.motion_detection = True

# Detect motion
while True:
if vc0706.motion_detected:
print("Motion detected!")
else:
print("....")