print("To make the gate auto open when a car is approaching!")
print("By: Danial Hafiz")
print("Date: 25/4/2024")
#import libraries
import servo_motor
from machine import Pin, PWM
from machine import sleep
#Pin declaration
servo_pin = Pin(33, Pin.OUT)
pir_pin = Pin(12, Pin.IN)
#parameter declaration
#Create an object name
toll_gate = servo_motor.Servo(pin=servo_pin)
#main program
while True:
motion_status=pir_pin.value()
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