Richard Creedy
Published © GPL3+

Project Tardis

Raspberry Pi Zero, flashy lights, PIR sensor, Tardis sound.

IntermediateShowcase (no instructions)449
Project Tardis

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
Development Board, Class D Audio Amplifier Module
Development Board, Class D Audio Amplifier Module
×1
LED 5mm blue
get them from wherever you can find them
×8
5v power supply
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian
python idle

Story

Read more

Code

TardisV2

Python
Full Code for Flashy Lights and Sound
#Tardis Project V2 by Richard Creedy

import RPi.GPIO as gpio
from time import sleep
import os, sys, subprocess

gpio.setwarnings(False)

gpio.setmode(gpio.BOARD)
LED=32

gpio.setup(32,gpio.OUT)
PIR=31
gpio.setup(31,gpio.IN, pull_up_down=gpio.PUD_DOWN)
gpio.setup(16,gpio.IN)
def tardis(channel):
    print ("motion detectected")
    gpio.output(32, gpio.HIGH)
    subprocess.Popen(['aplay','/home/pi/tardis.wav'])
    sleep(1.25)
    gpio.output(32, gpio.LOW)
    sleep(0.55)
    gpio.output(32, gpio.HIGH)
    sleep(1.25)
    gpio.output(32, gpio.LOW)
    sleep(0.25)
    gpio.output(32, gpio.HIGH)
    subprocess.Popen(['aplay','/home/pi/tardis.wav'])
    sleep(1.25)
    gpio.output(32, gpio.LOW)
    sleep(0.55)
    gpio.output(32, gpio.HIGH)
    sleep(1.25)
    gpio.output(32, gpio.LOW)

    sleep(10)
    

gpio.add_event_detect(31,gpio.RISING,callback=tardis,bouncetime=3600)

try:  
    print ("Waiting for motion")
    gpio.wait_for_edge(16,gpio.RISING) 
    print ("quitting") 
  
except KeyboardInterrupt:  
    gpio.cleanup()   


    
    


    

Credits

Richard Creedy

Richard Creedy

1 project • 0 followers

Comments