Im trying to figure out some python code that essentially will detect movement/motion of the LSM6DSOX Accelerometer and will further execute code to activate an raspberry pi camera to take a picture once movement is detected.
import time import board from adafruit_lsm6ds.lsm6dsox
import LSM6DSOX sensor = LSM6DSOX(i2c)
camera = PiCamera()
accel_x,accel_y,accel_z = sensor.acceleration
class Watcher:
def __init__(self, value):
self.variable = value
def set_value(self, new_value):
if self.variable != new_value:
self.post_change()
def post_change(self):
camera.capture("/home/pi/Pictures/img.jpg")
print("Done.")
time.sleep(2) def main():
def main():
Watcher.setValue(self,accel_x)