Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import serial
- import RPi.GPIO as GPIO
- import mysql.connector
- cnx = mysql.connector.connect(user='necro', database='cards')
- cursor = cnx.cursor()
- query = ("SELECT RFID, active FROM cards WHERE RFID = '%s';")
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(Majak,GPIO.OUT)
- GPIO.setup(Zamek,GPIO.OUT)
- GPIO.setup(Zvonek,GPIO.IN)
- GPIO.setup(Dvernik,GPIO.IN)
- GPIO.output(23,False)
- GPIO.output(24,False)
- PortRF = serial.Serial('/dev/ttyAMA0',9600)
- while True:
- if GPIO.input(Zvonek,True):
- GPIO.output(Majak,True)
- time.sleep(5)
- GPIO.output(Majak,False)
- if GPIO.input(Dvernik,True):
- GPIO.output(Zamek,True)
- time.sleep(10)
- GPIO.output(Zamek,False)
- ID = ""
- read_byte = PortRF.read()
- if read_byte=="\x02":
- for Counter in range(12):
- read_byte=PortRF.read()
- ID = ID + str(read_byte)
- print hex(ord( read_byte))
- print ID
- cursor.execute(query, (ID))
- for (name, active) in cursor:
- if active == 1;
- GPIO.output(Zamek,True)
- time.sleep(5)
- GPIO.output(Zamek,False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement