IR Range Finder Interfacing with Raspberry Pi and Python

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
You can leave a response, or trackback from your own site.
Leave a Reply to the article

Learning & Certifications
Follow Us
Facebook Icon   Linked In Icon   Twitter Icon  
Validation and Recognition

Valid CSS! Valid HTML5!          Protected by Copyscape