Arduino 控制RC522RFID射频模块读取UID并输出到串口

本文介绍了如何在ArduinoUno上通过MFRC522库连接RFID射频模块,实现读取卡片的UID并将数据输出到串口的过程,包括硬件连接和示例代码。
摘要由CSDN通过智能技术生成

Arduino 控制RC522RFID射频模块读取UID并输出到串口

一、Arduino 与RC522硬件连接

二、Arduino 读取UID,并将其输出到串口例程

/*

【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)

MFRC-522 RC522 RFID射频 IC卡感应模块读卡器S50复旦卡钥匙扣模组

1、工具-管理库-搜索“MFRC522”库-安装

2、项目:使用MFRC522 RFID和Arduino读写标签

3、RFID与Arduino Uno的连线

SDA------------------------Digital 10

SCK------------------------Digital 13

MOSI----------------------Digital 11

MISO----------------------Digital 12

IRQ------------------------不用连接

GND-----------------------GND

RST------------------------Digital 9           

3.3V------------------------3.3V (千万不要连接到5V接口!!!)



*/

#include <SPI.h>

#include <MFRC522.h>

#define SS_PIN 10

#define RST_PIN 9

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.



void setup() {

 Serial.begin(9600); // Initialize serial communications with the PC

 SPI.begin(); // Init SPI bus

 mfrc522.PCD_Init(); // Init MFRC522 card

 Serial.println("Scan PICC to see UID and type...");

}



void loop() {

 // Look for new cards

 if ( ! mfrc522.PICC_IsNewCardPresent()) {

  return;

 }

 // Select one of the cards

 if ( ! mfrc522.PICC_ReadCardSerial()) {

  return;

 }

 // Dump debug info about the card. PICC_HaltA() is automatically called.

 mfrc522.PICC_DumpToSerial(&(mfrc522.uid));

}

三、实验效果演示

Arduino_rc522

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值