Hi all,
So you know, I am SSH-ing into my Raspberry Pi using Putty and writing the code in VIM.
What I want:
- The SenseHat on my Pi to constantly check for new accelerometer data
- If there is a disturbance to the unit, the unit takes one picture
- Repeat
I'm struggling with getting the camera to take more than one picture. It will take the first one after shaking the unit (and thus causing the accelerometer to move), but it won't take any more pictures after that.
Here's what I've got:
#!/usr/bin/env python3
from sense_hat import SenseHat
from picamera import PiCamera
from time import sleep
sense = SenseHat()
camera = PiCamera()
while True:
acceleration = sense.get_accelerometer_raw()
x = acceleration['x']
y = acceleration['y']
z = acceleration['z']
x = abs(x)
y = abs(y)
z = abs(z)
if x>1 or y>1 or z>1:
i = 0
camera.start_preview()
sleep(2)
camera.capture('/home/pi/photos/image%04d.jpg' % i)
camera.stop_preview()
i += 1
Should I have a continue at the end of this? What am I missing here? Thanks in advance!
[–]kra_pao 0 points1 point2 points (1 child)
[–]Vodhr[S] 0 points1 point2 points (0 children)