print("Program for display oled screen the signal from motion sensor ")
print("Date: 4/11/2024")
print("by jd")
#Import libraries/module
import oled_library
from machine import Pin,SoftI2C
from machine import Pin
from utime import sleep
#Pin declaration
oled_Pin = SoftI2C(scl=Pin(22), sda=Pin(21))
PIR_pin = Pin(13, Pin.IN)
RedLED_pin = Pin(2,Pin.OUT)
#Object Declaration (This for sensor with library only)
#Object_name = LibraryName.ClassName(.....)
Screen = oled_library.SSD1306_I2C(width= 123, height= 64, i2c= oled_Pin)
#Parameter declaration
#Main program
while True:
PIR_value = PIR_pin.value() #.value = digital .read = analog
print("\nThe motion status is", PIR_value)
print("----------------------------------")
if PIR_value == 1:
for m in range (5):
RedLED_pin.on()
sleep(0.5)
RedLED_pin.off()
sleep(0.5)
Screen.fill(0) #0 means black , 1 means white
Screen.text("FATALITY", 32, 28, 1) #column, row, color font
Screen.show()
else:
RedLED_pin.off()
PIR_value = 0 #Iniatialize the sensor value
sleep(1)