我需要将RFID读取器与LC监视器和Raspberry Pi 3连接起来,以便当RFID检测到LCD显示屏上显示一条消息时,如何将这两个代码连接起来?
我一直在浏览互联网,但是没有人真正回答我的问题,或者他们迷失了答案。用于检查卡的代码可与LCD单独使用,按我告诉的方式处理消息。
import time
import Adafruit_CharLCD as LCD
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
#Raspberry Pi pin setup
lcd_rs = 36
lcd_en = 24
lcd_d4 = 23
lcd_d5 = 17
lcd_d6 = 18
lcd_d7 = 22
lcd_backlight = 2
#Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows = 2
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
lcd.clear()
lcd.message('Hello\nWorld!')
#Wait 5 seconds
time.sleep(2.0)
lcd.clear()
text = raw_input("Type Something to be displayed: ")
lcd.message(text)
#Wait 5 seconds
time.sleep(2.0)
lcd.clear()
lcd.message('Goodbye\nWorld!')
time.sleep(2.0)
lcd.clear()
text = input(id)
lcd.message(id)
GPIO.cleanup()
reader = SimpleMFRC522()
print("Bring the card closer")
try:
id, text = reader.read()
print(id)
print(text)
finally:
GPIO.cleanup()
我希望当RFID读取卡时,一条消息会在LCD监视器上弹出,提示一条消息。在整个编程世界中,我是新手,任何帮助将不胜感激。