print("Parking Mengundur")
print("Date: 2/4/2026")
#import libraries
from machine import Pin, SoftI2C
import oled_library
import ultrasonis_library
from utime import sleep
from machine import Pin, PWM
#Pin Declaration
oled_pin = SoftI2C( scl = Pin(22) , sda = Pin(21) )
TRIG = Pin(27)
ECHO = Pin(14)
red = Pin(5, Pin.OUT)
blue = Pin(17, Pin.OUT)
yellow = Pin(16, Pin.OUT)
buzzer = PWM(18, Pin.OUT)
#object declaration
#Required ONLY when external library is used
#ObjectName = Library name.Classname (...........)
screen = oled_library.SSD1306_I2C(width = 128, height = 64 , i2c = oled_pin )
reverse = ultrasonis_library.HCSR04(trigger_pin =TRIG, echo_pin =ECHO)
#Main Program
while True:
#measure nearby object
distance_in_cm = reverse.distance_cm()
#display o terminal
print("object terdekat adalah : ", distance_in_cm, "cm")
print("----------------------------------------------")
if distance_in_cm >= 200:
screen.fill(1) #1 for white, 0 for black
screen.text("LAB PROF PEKKA:", 10, 20, col=0)
screen.show()
for loop in range(5):
red.on()
blue.off()
yellow.off()
buzzer.freq(1200)
buzzer.duty(500)
sleep(0.3)
elif 100 <= distance_in_cm < 200:
screen.fill(1) #1 for white, 0 for black
screen.text("LAB PROF PEKKA:", 10, 10, col=0)
screen.text("THIS IS", 10, 30, col=0)
screen.text("SUICIDE LAB", 10, 50, col=0)
screen.show()
for loop in range(5):
blue.on()
red.off()
yellow.off()
buzzer.freq(1200)
buzzer.duty(0)
sleep(0.3)
else:
screen.fill(1) #1 for white, 0 for black
screen.text("WELCOME TO THE MOST INTERESTING LAB", 5, 10, col=0)
screen.text("Are you ready", 5, 30, col=0)
screen.text("TO HAVE FUN???", 5, 50, col=0)
screen.show()
for loop in range(5):
yellow.on()
red.off()
blue.off()
buzzer.freq(1200)
buzzer.duty(0)
sleep(0.3)
sleep(1)