what want ultra sonic trigger scream,flash exorcist girl, , snap photo. have butchered code awesome
scare mirror raspberry pi 3
using ultrasonic trigger flash picture , play scream.
'''
scare mirror raspberry pi 3
using ultrasonic trigger flash picture , play scream.
'''
code: select all
# modules import time import datetime import rpi.gpio gpio import subprocess import pygame import picamera random import choice #setup pygame pygame.init() pygame.mixer.init() # setup gpio use logical pin numbering gpio.setwarnings(false) gpio.setmode(gpio.bcm) # create variables global distance camera = picamera.picamera() time import sleep picamera import picamera trigger = 23 echo = 24 song1 = "./song1.mp3" song2 = "./song2.mp3" song3 = "./song3.mp3" # setup gpio pins gpio.setup(trigger,gpio.out) gpio.setup(echo,gpio.in) #define functions def ultra(sensor): global distance if sensor == 0: time.sleep(0.3) signaloff = 0 signalon = 0 gpio.output(trigger, true) time.sleep(0.00001) gpio.output(trigger, false) while gpio.input(echo)==0: signaloff = time.time() while gpio.input(echo)==1: signalon = time.time() timepassed = signalon - signaloff distance = timepassed * 17000 return distance else: print ("error.") def music(x): pygame.mixer.music.load(x) pygame.mixer.music.play(1) def photo(x): f=open('cottage.jpg', 'r+') jpgdata = f.read() f.close() # main body of code #cue tell me system ready music("./song1.mp3") while true: ultra(sensor) songlist = [song1,song2,song3] chosen = choice(songlist) if distance < 30: a=datetime.datetime.now() a=str(a) a=a[0:19] alert = ("scare detected at"+str(a)) print(f) pic = (a)+(".jpg") camera.resolution = (1024, 768) camera.capture('cottage.jpg') music(chosen) time.sleep(10) camera.close() else: print("waiting scare") time.sleep(1)
i'm guessing you've got week working?
first off need post code between code tags (read sticky) can read properly.
secondly take time , google need know, code posted mess, "butchered" understatement.
people here need started.
dave.
first off need post code between code tags (read sticky) can read properly.
secondly take time , google need know, code posted mess, "butchered" understatement.
people here need started.
dave.
raspberrypi
Comments
Post a Comment