print("Program: To detect motion")
print ("Date: 4/11/2024")
print ("Created by: Nilla")
#import modules/libraries
from machine import Pin
from utime import sleep
#Pin declaration
PIR_pin = Pin(25, Pin.IN)
Red_Led_pin = Pin(4, Pin.OUT)
oled_pin = SoftI2C(scl=Pin(21), sda=Pin(22))
#Parameter declaration
#Main Program
while True: #infinity loop
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):
Red_Led_pin.ON ()
sleep(0.5)
Red_Led_pin.OFF ()
sleep (0.5)
else:
Red_Led_Pin.OFF()
sleep (1)