Skip to main content
Engineering LibreTexts

Grove IR Interrupter Detector

  • Page ID

    Grove IR Interrupter Detector.png

    The grove infrared reflector sensor is a digital device.

    Therefore it interfaces through a digital port.  The required input voltage is 5 volts.

    It is sensitive to reflected IR from 0 to 4.5 cm (1.77 inches).


    # SwitchDoc Labs, August 2019
    # Modification by Phil H Williams, May 25, 2021
    import RPi.GPIO as GPIO
    import time
    # Set the digital port (pin)
    pin = 5
    GPIO.setmode(GPIO.BCM)           # Set up the GPIO.
    GPIO.setup(pin, GPIO.IN)         # In this example a digital input is used.
    while (True):
     if (GPIO.input(pin) == 0):      # Read the condition of the input on the pin and see if it is high (1) or low (0).
       print ('Object Detected')     # The if else block.
       print ('Object NOT Detected')  




    • Was this article helpful?