电子标签RFID =================== .. figure:: /_static/products/ledong-module/static/图片/RFID-H.png :width: 55% :align: center 概述 -------------------- 能有效识别射频卡ID并读写信息,可模拟实现电子钱包的充值和扣费功能。 技术参数 ------------------- 工作电压: VCC 3.3V -5V 模块尺寸:24*48mm 固定安装:2个兼容塑料积木通孔 探测距离:0.5-1cm 数据类型:ID和电子钱包信息 引脚定义 ------------------- ===== ======== 引脚 定义 ===== ======== GND 地 VCC 电源 SCL I2C时钟 SDA I2C数据 ===== ======== 示例程序 ------------------- **1、按A键获取射频卡序列号并初始化设置并RGB亮红灯,按B键对射频卡充值并亮绿灯。** **2、掌控板OLED屏显示RFID序列号和当前余额。。** .. code-block:: python from mpython import * from bluebit import * x = None y = None import time def on_button_a_pressed(_): global y, x rf = scan_rfid.scanning() x = rf.serial_number() rf.set_purse() y = 0 rgb.fill((int(255), int(0), int(0))) rgb.write() time.sleep_ms(1) time.sleep(0.1) rgb.fill(( 0, 0, 0) ) rgb.write() time.sleep_ms(1) button_a.event_pressed = on_button_a_pressed def on_button_b_pressed(_): global y, x rf = scan_rfid.scanning() rf.increment(1) y = rf.get_balance() rgb.fill((int(51), int(204), int(0))) rgb.write() time.sleep_ms(1) time.sleep(0.1) rgb.fill(( 0, 0, 0) ) rgb.write() time.sleep_ms(1) button_b.event_pressed = on_button_b_pressed scan_rfid = Scan_Rfid() while True: oled.fill(0) oled.DispChar(str(str('序列号: ') + str(x)), 0, 0, 1) oled.DispChar(str(str('余额: ') + str(y)), 0, 16, 1) oled.show() .. figure:: /_static/products/ledong-module/static/examples/RFID.png :width: 100% :align: center