Combined PIR, Camera, LED and ScrollPhatHD projects

Hi Folks

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
import signal
import time
import scrollphathd
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 (“Active”)
print (“Press Ctrl+c to end program”)

while True:
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 # 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”)

I believe you have to do a scrollphathd.clear() followed by a
Something like that.

Thanks for the response, I have tried the clear and show commands and they sort of work but I can’t workout where to place them. I have tried several places and each time all it does is make the Scroll Phat HD flash the beginning of the message for a split second and then clears the screen.

I think I would put it in the GPIO.output(led, False) #Turn off LED section.
Try changing # Scroll the buffer content
scrollphathd.scroll() # Wait for 0.1s
scrollphathd.clear() # clear the buffer content # show the blank buffer

Disclaimer, I am far from any kind of Python expert. ;)