Beispiel #1
0
    def __init__(self):
        self.valid = self.read_database()
        self.green_led = 8
        self.red_led = 10
        self.servo = 40
        self.buzzer = 38
        gpio.setmode(gpio.BOARD)
        gpio.setup(self.red_led, gpio.OUT)
        gpio.setup(self.green_led, gpio.OUT)
        gpio.setup(self.buzzer, gpio.OUT)

        gpio.setup(self.servo, gpio.OUT)

        gpio.output(self.red_led, 1)
        gpio.output(self.green_led, 0)
        gpio.output(self.buzzer, gpio.LOW)
        signal.signal(signal.SIGINT, self.end_read)
        self.IDreader = MFRC522.Reader()
        self.gate = gpio.PWM(self.servo, 50)
        self.gate.start(2.5)
Beispiel #2
0
    def __init__(self):
        self.valid = self.read_database()
        self.green_led = 8
        self.red_led = 10
        self.servo = 40
        self.buzzer = 38

        gpio.setmode(gpio.BOARD)

        gpio.setup(self.red_led, gpio.OUT)
        gpio.setup(self.green_led, gpio.OUT)
        gpio.setup(self.buzzer, gpio.OUT)
        gpio.setup(self.servo, gpio.OUT)

        gpio.output(self.red_led, 1)
        gpio.output(self.green_led, 0)
        gpio.output(self.buzzer, gpio.LOW)

        signal.signal(signal.SIGINT, self.end_read)
        self.IDreader = MFRC522.Reader()

        self.gate = gpio.PWM(self.servo, 50)
        self.gate.start(2.5)

        self.host = ''
        self.port = 5000
        self.bufsiz = 1024
        self.addr = (self.host, self.port)
        self.tcpsersock = socket(AF_INET, SOCK_STREAM)
        try:
            (self.tcpsersock).bind(self.addr)
        except OSError:
            pass
            (self.tcpsersock).close()
            self.tcpsersock = socket(AF_INET, SOCK_STREAM)
        (self.tcpsersock).listen(5)
        (self.tcpsersock).settimeout(60)
Beispiel #3
0
continue_reading = True


# Capture SIGINT for cleanup when the script is aborted
def end_read(signal, frame):
    global continue_reading
    print("Ctrl+C captured, ending read.")
    continue_reading = False
    GPIO.cleanup()


# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)

# Create an object of the class MFRC522
MIFAREReader = MFRC522.Reader(0, 0, 22)

# This loop keeps checking for chips. If one is near it will get the UID and authenticate
while continue_reading:
    # Scan for cards
    (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)

    # If a card is found
    if status == MIFAREReader.MI_OK:
        print("Card detected")

    # Get the UID of the card
    (status, uid) = MIFAREReader.MFRC522_Anticoll()

    # If we have the UID, continue
    if status == MIFAREReader.MI_OK: