IR Range Finder Interfacing with Raspberry Pi and its Python application program. It is step by step tutorial on Digital sensor Interfacing with Raspberry Pi.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state=GPIO.input(18)
if input_state == False:
print('IR Low')#detect - LED Glow
else:
print('IR High')#not detect - LED Off
time.sleep(1)
Pin Connection
GPIO Pin 2 -> VCC (5 Volt)
GPIO Pin 6 -> Ground
GPIO Pin 18 -> Digital Input

March 25th, 2019
Nilesh Chaurasia
Posted in
Tags:
