-
-
Save renatojobal/8166b6e50ddee54ec6469f2559e4515c to your computer and use it in GitHub Desktop.
Create a simple GUI for USB RFid Reader EM4100 using Raspberry Pi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import LED, Buzzer | |
from guizero import App, Box, Text, TextBox, warn | |
import csv | |
led8 = LED(19) | |
def clearDisplay(): | |
print("Clear display") | |
rfidStatus.value = "---" | |
rfidText.value = "" | |
led8.off() | |
rfidStatus.repeat(1000, checkRFidTag) | |
def checkRFidTag(): | |
tagId = rfidText.value | |
if tagId != "": | |
RFidRegistered = False | |
print(tagId) | |
with open("Database.csv") as csvfile: | |
reader = csv.DictReader(csvfile) | |
for row in reader: | |
if row["RFid"] == tagId: | |
RFidRegistered = True | |
print("Welcome " + row["User"]) | |
rfidStatus.value = "Welcome " + row["User"] | |
led8.on() | |
rfidStatus.after(5000, clearDisplay) | |
if RFidRegistered == False: | |
print("RFid tag is not registered") | |
rfidStatus.value = "RFid tag is not registered" | |
rfidStatus.after(3000, clearDisplay) | |
rfidStatus.cancel(checkRFidTag) | |
app = App(title="RFID EM4100 Simple GUI", width=350, height=150, layout="auto") | |
instructionText = Text(app, text="Click on the text button below\nand scan your RFid tag.") | |
rfidText = TextBox(app) | |
rfidStatus = Text(app, text="---") | |
rfidStatus.repeat(1000, checkRFidTag) | |
designBy = Text(app, text="Design by Idris - Cytron Technologies", align="bottom") | |
app.display() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment