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)
代码不会循环该函数。
发布于 2018-06-18 03:42:24
据我所知,当解释器读取exit()语句时,它会中断您的无限循环并终止程序执行。
https://stackoverflow.com/questions/50899028
复制相似问题