I am using pimylifeup library to read RFId card. But after id, text = reader.read(), I don't get reading from 4×4 keypad. I tried with both BOARD and BCM numbering to read keypad. I have to exit the program after a key press. The program is available on my GitHub repository.
Spawn a new thread to read keypad while RFID is being scanned, then read its data and kill it the moment RFID is done being scanned. In the code below, I'll demonstrate the use of processes.
At the top of your script (
from multiprocessing import Process, Pipe, Value
then, before line 79 (which shall be line 80 once you insert the above), add a call to a procedure, built to read keypad input while the RFID is being scanned:
parent_conn, child_conn = Pipe() #Data which shall contain keys pressed while the RFID is being read. v = Value('i', 0) #The amount of keys pressed while RFID is being scanned p = Process(target=readKeypadWhileRFIDIsScanned, args=(child_conn, v)) p.start() id, text = reader.read() keysPressed =  for i in range(0, v.value): keysPressed.append(parent_conn.recv()) p.join() #We don't need it anymore """Now, add a loop to process each key stored in the list keysPressed"""
readKeypadWhileRFIDIsScanned() would be something like:
def readKeypadWhileRFIDIsScanned(q, v): while True: key = get_key() if key: v += 1 q.send(key)
And I reccomend you indent the code starting from line 7 and encapsulate it in to a main() method, finishing by adding:
if __name__ == '__main__': main()
to the end of the script; it's both better format and more readable.