print("Production Line Safety Monitoring & Alert System")
print("Mini Project IOT")
print("By : Iqbal, Saiful, Fathull")
# Import Libraries
import servo_library
import servo2_library
from machine import Pin, PWM
from time import sleep
# Pin Declarations
servo_pin = Pin(12, Pin.OUT) # Servo for entrance gate
servo2_pin = Pin(13, Pin.OUT) # Servo for exit gate
PIR_sensor = Pin(27, Pin.IN)
PIR_sensor2 = Pin(14, Pin.IN)
# Parameter Declaration
NUMBER_OF_PEOPLE = 0
# Object Name
gate_entrance = servo_library.Servo(pin=servo_pin)
gate_exit = servo2_library.Servo(pin=servo2_pin)
# Main Program
while True:
motion_entrance = PIR_sensor.value()
motion_exit = PIR_sensor2.value()
if motion_entrance:
gate_entrance.move(angle=90)
sleep(0.5)
gate_entrance.move(angle=180)
sleep(4)
NUMBER_OF_PEOPLE += 1
print("\nTOTAL PEOPLE IN MALL = ", NUMBER_OF_PEOPLE)
elif motion_exit:
gate_exit.move(angle=90)
sleep(0.5)
gate_exit.move(angle=0)
sleep(4)
NUMBER_OF_PEOPLE -= 1
print("\nTOTAL PEOPLE IN MALL = ", NUMBER_OF_PEOPLE)