def main(): global Unreaded LCM.lcd_init() LCM.lcd_string(1, "Welcome LEGOMail") LCM.lcd_string(2, "") mail = Thread(target=check_msg, args=()) mail.setDaemon(True) mail.start() # start the bttom monitor GPIO.setup(BtnGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: try: GPIO.wait_for_edge(BtnGPIO, GPIO.FALLING) # waiting for falling edge interrupt subprocess.call(["aplay", VoiceMsg_path]) # play the received msg LCM.lcd_string(1, "Wait for Msg") if Unreaded: Unreaded = False LCM.lcd_string(2, "Play old Msg") except KeyboardInterrupt: GPIO.remove_event_detect(BtnGPIO) GPIO.cleanup() print "main terminate"