Greetings All,
I am working on a project where I have to integrate ultrasonic sensor, I have bought Rock Pi 4 C+,
I have connected with Raspberry Pi Solderless Breakout kit,
Rpi.GPIO is not being installed giving error, tried running
====================== command ===================
~ sudo pip install RPi.GPIO
====================== command ===================
while working with periphery i installed it but the code is runninng but is not getting answer form echo and trig pin.
I have pasted my code bellow, if some one can help
#======================================Code===================================
import time
from periphery import GPIO
TRIG_PIN = 17
ECHO_PIN = 18
trig = GPIO(TRIG_PIN, “out”)
echo = GPIO(ECHO_PIN, “in”)
trig.write(False)
time.sleep(0.1)
trig.write(True)
time.sleep(0.00001)
trig.write(False)
while echo.read() == 0:
start_time = time.time()
while echo.read() == 1:
end_time = time.time()
duration = end_time - start_time
distance = duration * 34300 / 2 # Speed of sound = 343 m/s
distance = round(distance, 2) # Round to 2 decimal places
print(“Distance: {} cm”.format(distance))
trig.close()
echo.close()
====================== Code ===================