def callback(channel):
print("WARNING! FLAME DETECTED!!!\n")
pygame.mixer.music.play()
firebase.post("/Report/Location", alamat)
firebase.post("/Report/Time", masa)
lcd_string(" FIRE DETECTED ",LCD_LINE_1)
lcd_string(masa,LCD_LINE_2)
print ("SUCCESSFULL REPORTED\n" +"Time : " + masa + "\nLocation : " + alamat)
GPIO.add_event_detect(channel, GPIO.FALLING, bouncetime=300) # let us know when 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(10)
lcd_init()
您好,有人可以解释一下为什么上面这段代码循环功能2次。当我删除
时,这让我更加困惑firebase.post("/Report/Location", alamat)
firebase.post("/Report/Time", masa)
代码不会循环该函数。
答案 0 :(得分:0)
当解释器读取exit()语句时,据我所知,它突破了无限循环,程序执行终止。