Skip to content

Commit 05b54a0

Browse files
authored
Add files via upload
1 parent b241dde commit 05b54a0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

temp_ir.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import RPi.GPIO as GPIO
2+
import time
3+
4+
sensor = 16
5+
buzzer = 18
6+
7+
GPIO.setmode(GPIO.BOARD)
8+
GPIO.setup(sensor,GPIO.IN)
9+
GPIO.setup(buzzer,GPIO.OUT)
10+
11+
GPIO.output(buzzer,False)
12+
print("IR Sensor Ready.....")
13+
14+
15+
try:
16+
while True:
17+
if GPIO.input(sensor):
18+
time1 = time.time()
19+
GPIO.output(buzzer,True)
20+
time2= time.time()
21+
print("Object Detected in "+str(time2-time1))
22+
while GPIO.input(sensor):
23+
time.sleep(0.2)
24+
else:
25+
GPIO.output(buzzer,False)
26+
27+
28+
except KeyboardInterrupt:
29+
GPIO.cleanup()
30+

0 commit comments

Comments
 (0)