print("Making ultrasonuc working")
print("by:itszaham")
print("date:22/4/24")

#import libraries
import ultrasonic_library
from machine import Pin

#pin declaration
TRIG = Pin(13)
ECHO = Pin(12)
BUZZER = Pin(14)

#Parameter declaration


#create an object name --> Name = library_name.class_name(.....)
sensor_parking = ultrasonic_library.HCSR04(trigger_pin=TRIG,echo_pin = ECHO, echo_timeout_us=500*2*30)

#maim program
while True:
  distance_mm = sensor_parking.distance_mm()
  distance_cm = sensor_parking.distance_cm()
  print("jarak kereta dari dinding adalah", distance_cm,"cm")
  print("jarak kereta dari dinding adalah", distance_mm,"mm")

  if distance_cm >= 200:
    buzzer.init(freq=500, duty=0)
 elit 100 < distance_cm < 200:
    
Loading
esp32-devkit-v1