Commit 0bb40b70 authored by Aadil M. Alli's avatar Aadil M. Alli

Delete Ultrasonic_Ranging.py

parent 56eb9430
import RPi.GPIO as GPIO
import time
TRIG = 22
ECHO = 27
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(TRIG,GPIO.OUT,initial=GPIO.LOW)
GPIO.setup(ECHO,GPIO.IN)
def dist():
GPIO.output(TRIG,GPIO.HIGH)
time.sleep(0.000015)
GPIO.output(TRIG,GPIO.LOW)
while not GPIO.input(ECHO):
pass
t1 = time.time()
while GPIO.input(ECHO):
pass
t2 = time.time()
return (t2-t1)*34000/2
try:
while True:
print "Distance:%0.2f cm" % dist()
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment