def ScanPressed(pin): global time_stamp # put in to debounce global debounce global PoweredOff global Scanning global Going global camera global ledPinScanning global ledPinFoundQR global bFoundQR global commandString time_now = time.time() if (time_now - time_stamp) >= debounce and PoweredOff==False and Scanning==False and Going==False: # Play a sound to show that we are scanning audio.playSound(0) # Flag that we are scanning Scanning = True print("Scan Button pressed") # Call python script to try and find QR code from webcam image GPIO.output(ledPinScanning, True) # Turn on the "Scanning" LED GPIO.output(ledPinFoundQR, False) # Ensure Found QR LED OFF # Try to find a QR code from the camera. QRCode = qrscanner.FindQRCode(ledPinScanning, camera, 10) if (QRCode != ""): # Play sound that we found one audio.playSound(10) # Found a QR Code, Strip out the command portion of the string commandString = parseQR.parseOutCommand(QRCode) # Flag that we found a QR code bFoundQR = True # Ensure Found QR LED OFF GPIO.output(ledPinFoundQR, True) # Turn off the "Scanning" LED GPIO.output(ledPinScanning, False) Scanning = False time_stamp = time_now