print("Ayiee =-=")
print("Automatic Door Mesra Mall")
# IMPORT LIBRARIES
from machine import Pin, PWM, I2C
from time import sleep
import oled_library
# PIN DECLARATION
pir = Pin(12, Pin.IN)
servo = PWM(Pin(15), freq=50)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = oled_library.SSD1306_I2C(128, 64, i2c)
buzzer = PWM(Pin(14, Pin. OUT))
# SERVO CONTROL
def door_open():
servo.duty(115)
print("Door OPEN")
def door_close():
servo.duty(40)
print("Door CLOSED")
# OLED DISPLAY
def show_open():
oled.fill(0)
oled.text("---WELCOME----", 5, 10)
oled.text("--TO M3 MALL---", 5, 25)
oled.show()
buzzer.freq(400)
buzzer.duty(2)
sleep(0.1)
buzzer.freq(200)
buzzer.duty(0)
sleep(0.1)
def show_closed():
oled.fill(0)
oled.text("--THANK YOU--", 5, 10)
oled.text("--FOR COMING--", 5, 25)
oled.show()
buzzer.freq(200)
buzzer.duty(0)
sleep(0.1)
buzzer.freq(300)
buzzer.duty(0)
sleep(0.1)
# START
door_close()
show_closed()
sleep(5)
# MAIN PROGRAM
while True:
if pir.value() == 1:
print("Motion Detected")
door_open()
show_open()
sleep(10)
else:
print("No Motion")
door_close()
show_closed()
sleep(10)