print("\nThis Program Will Test the gate auto open when a car is approaching")
print("Created By : MUHAMMAD ASYRAAF BIN ASRI")
print("Date: 25/4/2024\n")
#Import libraries/modules
import servo_library
from machine import Pin, PWM
from utime import sleep
#Pin declaration
servo_pin = Pin(32,Pin.OUT)
PIR_pin = Pin(12,Pin.IN)
#Parameter declaration
#Create an OBJECT name for sensor with library ->Object_Name = Library modules.
toll_gate = servo_library.Servo(pin=servo_pin)
#main program
while True:
motion_status = PIR_pin.value() #.value (read digital value (1 or 0))
print("The motion status is",motion_status)
if motion_status == True:
for a in range (1):
toll_gate.move(angle=90)
sleep(3)
else :
toll_gate.move(angle=0)
sleep(3)
Loading
esp32-devkit-v1
esp32-devkit-v1