Hello there,
I have to connect the distance sensor to a Raspberry Pi for a project, but I have little experience and I am not very familiar with it.
I connected the distance sensor to the Raspberry Pi as I found it in the description:
- Ground to GND
- VIN to 3,3V
- OUT to GPIO 24
I also wrote a code on my Raspberry Pi that outputs “interrupt” if the sensor detects something.
import time
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN)
while True:
i = GPIO.input(24)
if i == 0:
print (‘interrupt’,i)
time.sleep(0.1)
elif i == 1:
print (‘no interrupt’,i)
time.sleep(0.1)
GPIO.cleanup()
My problem is that the LED on the sensor lights up all the time even though the description says that it should only light up if the output is low, indicating that the sensor is detecting something and If I execute the code, the sensor does not recognize anything.
Unfortunately I don’t know enough about this topic to find a solution.
Thanks.