I am using a Raspberry PI3 Model B and TCRT 5000 sensor to monitor movement. I am using a Python script(Python3) to read the data from the sensor. Script used -
#!/usr/bin/env python import RPi.GPIO as GPIO TrackPin = 11 LedPin = 12 def setup(): GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location GPIO.setup(LedPin, GPIO.OUT) # Set LedPin's mode is output GPIO.setup(TrackPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.output(LedPin, GPIO.HIGH) # Set LedPin high(+3.3V) to off led def loop(): while True: if GPIO.input(TrackPin) == GPIO.LOW: print ("...led on") GPIO.output(LedPin, GPIO.LOW) # led on else: print ("led off...") GPIO.output(LedPin, GPIO.HIGH) # led off def destroy(): GPIO.output(LedPin, GPIO.HIGH) # led off GPIO.cleanup() # Release resource if __name__ == '__main__': # Program start from here setup() try: loop() except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed. destroy()
Red color shows 5v power supply used with 220 ohm resistor Black color shows ground used with 220 ohm resistor Blue color shows output used with 10k ohm resistor
I tried to read data from GPIO 11 that is Pin 23. When do this the light on sensor indicating OUT always glows red.
I also changed the pin to Pin 11 which is GPIO 17. When do this the light on sensor indicating OUT won't glow. Output i am getting in both cases are always -
led off... led off... led off... led off... led off... led off... led off... led off... led off... led off... ..........
I went to many websites seeking solution but none worked for me. Am i doing something wrong ?