05-21-2019, 01:13 PM
Merhabalar proje ödevim için raspberry pi ile ateş algılandığında ses veren bir sistem yapmak istiyorum. Ateş sensörü ve buzzer kodlarını temin ettim fakat iki kodu birleştiremiyorum. Sadece ateş algılandığında ses veren bir kod istiyorum. Yardım edebilecek varsa çok sevinirim.(Aşağıdaki kodları birleştirmek yada elinde hazır kodu bulunan varsa olabilirim.
#flame sensor kodu
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
#GPIO SETUP
channel = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.IN)
def callback(channel):
print("flame detected")
GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300) # let us know the pin goes HIGH or LOW
GPIO.add_event_callback(channel, callback) # assign function to GPIO PIN, Run function on change
#infinite loop
while True:
time.sleep(1)
#buzzer kodu
import RPİ.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
while True:
GPIO.output(18,1)
time.sleep(1)
GPIO.output(18,0)
time.sleep(1)
#flame sensor kodu
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
#GPIO SETUP
channel = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.IN)
def callback(channel):
print("flame detected")
GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300) # let us know the pin goes HIGH or LOW
GPIO.add_event_callback(channel, callback) # assign function to GPIO PIN, Run function on change
#infinite loop
while True:
time.sleep(1)
#buzzer kodu
import RPİ.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
while True:
GPIO.output(18,1)
time.sleep(1)
GPIO.output(18,0)
time.sleep(1)