I'm trying to read the output of a photodiode sensor circuit by the Pi GPIO. The sensor circuit outputs roughly 3.3v, from an Op Amp when the sensor detects IR. Circuit Diagram:
N.B Op amp is a 358, not 741
Currently using this code on the Pi:
#!/usr/bin/python import RPi.GPIO as GPIO import os import time GPIO.setmode(GPIO.BOARD) #GPIO.setup(16, GPIO.IN) GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) #prev_input = 0 GPIO.setup(26, GPIO.OUT) GPIO.output(26, 0) while True: #input = GPIO.input(16) if (GPIO.input(16) ==1): print("ON") elif (GPIO.input(16) ==0): print("OFF") time.sleep(0.25) os.system('clear')
The output on the screen fluctuates between "ON" and "OFF".
As a test: If I plug the 3.3v of the Pi into a GPIO and read the input, I get a stable 'ON' state. Similarly, plugging into GND/disconnecting, I get a stable 'OFF' state.
I welcome any suggestions! Hope this edit helps make more sense?