#import library
from machine import Pin,SoftI2C
from time import sleep
from hcsr04 import HCSR04
from ssd1306 import SSD1306_I2C
# pin setup
ultrasonic = HCSR04(trigger_pin=18,echo_pin=19)
i2c =SoftI2C(scl=Pin(22),sda=Pin(21))
screen_width = 128
screen_height = 64
oled = SSD1306_I2C(screen_width,screen_height,i2c)
#clear screen
oled.fill(0)
oled.show()
while True:
distance = ultrasonic.distance_cm()
oled.fill(0)
# text,x,y,color
oled.text("Distance:",0,0)
oled.text(str(distance),50,0)
oled.show()