print("Let's make a LED Blinking,oled display & pir motion function")
print("Mohamad Faiz Haikal Bin Ishak")
print("Date: 24/11/2023")
#import all necessary library
import Oled_library
from utime import sleep
from machine import Pin, SoftI2C
#Declare Pin other VCC and GND
red_alarm = Pin(5, Pin.OUT) #Connect LED to GPIO 5
green_alarm = Pin(14, Pin.OUT) #Connect LED to GPIO 14
pir = Pin(13, Pin.IN) #Connect PIR to GPIO 13
pin_oled = SoftI2C(scl=Pin(22), sda=Pin(21))
#Let's create a name for our Oled Screen
#name = library name . class name
skrin = Oled_library.SSD1306_I2C(width=128, height=64, i2c=pin_oled)
#Let's send text to our Oled!
#colour black perlu pakai value "0" and white "1"
#y is row --> line 1 - 0,line 2 -10, line 3 - 20
#By default, the screen is in black colour
#Main program
while True: #Forever loop
motion = pir.value()
skrin.fill(1)
if motion == 1: #1 means there is motion. True/1
skrin.text("TOLONG", 10, 18, 0)
skrin.text('PENCURI MAII', 20, 40, 0)
for u in range (3):
red_alarm.on()
sleep(0.5)
red_alarm.off()
sleep(0.5)
green_alarm.off()
else:
skrin.text("ALHAMDULILLAH", 10, 20, 0)
skrin.text('SELAMAT', 20, 40, 0)
for u in range ():
green_alarm.on()
sleep(0.5)
green_alarm.off()
sleep(0.5)
red_alarm.off()
skrin.show()
sleep(2) #In every 2 sec, check the other motion..