So I am using a Raspberry Pi Zero to detect the signal from this NPN Inductive proximity sensor (its input supply range is 6 to 36V and the signal pin to output the same amount of voltage which we give as input).
The input supply of the proximity sensor is 6 volts from a step-up converter. Its output is also 6V, which is connected to a voltage divider made from resistors to bring it down to around 3V.
This 3V is then connected to a GPIO pin on the Raspberry Pi Zero, but it just doesn't detect it. The pin stays on "low" no matter what.
This 3V is then connected to a GPIO pin on the Raspberry pi zero but it just doesn't detect it. The pin stays on low no matter what.
The code I am using is this
import RPi.GPIO as GPIO import time p = 7 GPIO.setmode(GPIO.BCM) GPIO.setup(p,GPIO.IN, pull_up_down=GPIO.PUD_DOWN) print(GPIO.input(p)) while True: #print(GPIO.input(p)) if GPIO.input(p) == 1: print('Input was HIGH') else: pass time.sleep(0.5) I've tried changing the GPIO pin multiple times, but no result. I've also connected a 4x4 matrix keyboard and an LCD to the pi. Those work fine, only this Inductive proximity sensor is creating issues.
Please help. Any help is appreciated, I really need to complete this client's project om time.