on-internet
← Community

Python Raspeberry Pi Zero 2W: Ultrasonic input pin is always zero -

Stack Overflow ·

I have an issue with ultrasonic Sensor using my Raspberry Pi 2W. The input pin is always zero. I tried to change pins, but nothing changed. Here it is my sample code: import RPi.GPIO as gp import time import signal import sys def handler(signum, frame): print('\nPulizia gpio') time.sleep(0.5) gp.cleanup() sys.exit() inputPin = 12 # connect to echo via 1K resistor outputPin = 13 # connect to trig led = 7 gp.setmode(gp.BOARD) gp.setup(outputPin,gp.OUT) gp.setup(inputPin,gp.IN) gp.setup(led,gp.OUT) signal.signal(signal.SIGTSTP, handler) print(outputPin) print(inputPin) l = gp.output(led,True) o =

Comments

Sign in or sign up to comment and upvote.

No comments yet.