Hallo zusammen,
Ich hatte mal wieder lust zum basteln mit mein RFID Modul und den Raspi B2.
Nun habe ich ein Problem: Wenn an dem RFID Lesegerät der Token zu lange vorgehalten wird aus was für ein Grund auch immer wird meine schleife x mal ausgeführt.
Wie kann man eine Schleife bei irgendeiner Aktivität nur 1x ausführen lassen und dann wieder von vorne?
So das die serielle Schnittstelle nur 1x immer abgefragt wird.
Ich habe es auch schon mit time.sleep() versucht aber auch ohne erfolg.
Danke im vorraus
Code
import lcddriver
import time
import serial
import RPi.GPIO as GPIO
lcd=lcddriver.lcd()
GPIO.setmode(GPIO.BCM)
Tag1 = str('2700E66970D8')
GPIO.setup(23,GPIO.OUT)
GPIO.setup(24,GPIO.OUT)
GPIO.output(23,False)
GPIO.output(24,False)
lesen = serial.Serial('/dev/ttyAMA0',9600)
lcd.lcd_clear()
lcd.lcd_display_string("Bitte Chip!",1)
while 1:
ID = ""
read_byte = lesen.read()
if read_byte=="\x02":
time.sleep(3)
for Counter in range(12):
read_byte= lesen.read()
ID = ID + str(read_byte)
print hex (ord( read_byte))
lcd.lcd_clear()
lcd.lcd_display_string("Chip Bitte",1)
print ID
if ID == Tag1:
lcd.lcd_display_string("Bitte durchgehen!",1)
print "matched"
time.sleep(5)
lcd.lcd_clear()
lcd.lcd_display_string("Chip Bitte",1)
GPIO.output(23,True)
GPIO.output(24,False)
GPIO.output(23,False)
else:
lcd.lcd_clear()
lcd.lcd_display_string("Kein",1)
lcd.lcd_display_string("Durchgang!",2)
GPIO.output(23,False)
print "Access Denied"
GPIO.output(24,True)
GPIO.output(24,False)
time.sleep(5)
lcd.lcd_clear()
lcd.lcd_display_string("Chip Bitte",1)
GPIO.cleanup()
Alles anzeigen