I have been working on a project which uses a PIR to detect movement turn on an LED, Take a photo and scroll a message whilst movement is detected.
All the elements function as expected except when movement is no longer detected. I would like the Scroll Phat to reset its self so nothing is displayed.
I would consider myself technical but not a programmer.
I have cobbled together, with some tweeks a python script but for the life of me I can’t get it to clear the Scroll Phat.
I would be grateful for any pearls of wisdom.
Please see code below:
#PIR Sensor with LED, Camera and LED Scroll
import RPi.GPIO as GPIO
from picamera import PiCamera
from time import sleep
GPIO.setmode(GPIO.BOARD) #Set GPIO to pin numbering
pir = 8 #Assign pin 8 to PIR
led = 10 #Assign pin 10 to LED
camera = PiCamera()
GPIO.setup(pir, GPIO.IN) #Setup GPIO pin PIR as input
GPIO.setup(led, GPIO.OUT) #Setup GPIO pin for LED as output
print (“Sensor initializing . . .”)
time.sleep(2) #Give sensor time to startup
print (“Press Ctrl+c to end program”)
if GPIO.input(pir) == True: #If PIR pin goes high, motion is detected
print (“Motion Detected!”)
GPIO.output(led, True) #Turn on LED
scrollphathd.write_string(“POLICE POLITZI”, brightness=0.5,)
time.sleep(4) #Keep LED on for 4 seconds
GPIO.output(led, False) #Turn off LED
scrollphathd.show() # Scroll the buffer content
scrollphathd.scroll() # Wait for 0.1s
except KeyboardInterrupt: #Ctrl+c
pass #Do nothing, continue to finally
GPIO.output(led, False) #Turn off LED in case left on
GPIO.cleanup() #reset all GPIO
print (“Program ended”)