print("AUTOMATED PRAYER ROOM ASSISTANT")
print("ABDUL BAHIJ BIN AZAHAR")
print("51220223133")
print("6/5/2024")
# Import Libraries
from machine import Pin, SoftI2C
from utime import sleep
import servor_library
import oled_library
import ultrasonic_library
import servor2_library
# Pin Declaration
Motion_sensor = Pin(13, Pin.IN)
Lamp_1 = Pin(4, Pin.OUT)
Lamp_2 = Pin(2, Pin.OUT)
servo_motor = Pin(18, Pin.OUT)
oled_pin = SoftI2C(scl=Pin(22), sda=Pin(21))
TRIG = Pin(27)
ECHO = Pin(14)
door = Pin(5, Pin.OUT)
# Object Name
fan = servor_library.Servo(pin=servo_motor)
door_mosque = servor2_library.Servo(pin=door)
door_sensor = ultrasonic_library.HCSR04(trigger_pin=TRIG, echo_pin=ECHO, echo_timeout_us=500*2*30)
# Main Program
while True:
Lamp_1.off()
Lamp_2.off()
led_display = oled_library.SSD1306_I2C(width=128, height=64, i2c=oled_pin, external_vcc=False)
Moving_sensor = Motion_sensor.value()
distance_cm = door_sensor.distance_cm()
if Moving_sensor == True:
for angle in range(0, 359, 10): # Move from 0 to 359 degrees
Lamp_1.on()
Lamp_2.on()
fan.move(angle)
sleep(0.1)
led_display.fill(1)
led_display.text("SOLAT ITU TIANG", x=5, y=10, col=0)
led_display.text("AGAMA", x=42, y=20, col=0)
led_display.show()
elif distance_cm >=160:
door_mosque.move(angle=90)
else:
door_mosque.move(angle=0)
Lamp_1.off()
Lamp_2.off()
fan.move(359) # Move servo to 0 degrees to stop movement
sleep(0.1)Loading
esp32-devkit-v1
esp32-devkit-v1