标题:
Arduino RC522 RFID库文件源码资料
[打印本页]
作者:
WESF
时间:
2018-5-4 14:23
标题:
Arduino RC522 RFID库文件源码资料
0.jpg
(25.32 KB, 下载次数: 81)
下载附件
2018-5-5 02:06 上传
RFID实验源程序如下:
/******************************************************************************
----------------本例程仅供学习使用,未经作者允许,不得用于其他用途。-----------
------------------------版权所有,仿冒必究!-----------------------------------
----------------1.开发环境:Arduino IDE-----------------------------------------
----------------2.测试使用开发板型号:Arduino Leonardo or Arduino UNO R3-------
----------------3.单片机使用晶振:16M------------------------------------------
----------------5.作者:神秘藏宝室---------------------------------------------
******************************************************************************/
#include "RC522.h"
#include <SPI.h>
#define Relay 2
//4 bytes Serial number of card, the 5 bytes is verfiy bytes
unsigned char serNum[5];
void setup()
{
Serial.begin(9600);
Serial.print("Ilovemcu.taobao.com");
pinMode(Relay,OUTPUT);
SPI.begin();
pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(chipSelectPin, LOW); // Activate the RFID reader
pinMode(NRSTPD,OUTPUT); // Set digital Reset , Not Reset and Power-down
MFRC522_Init(); //初始化RFID
}
void loop()
{
unsigned char status;
unsigned char str[MAX_LEN];
// Search card, return card types
status = MFRC522_Request(PICC_REQIDL, str);
if (status == MI_OK) //读取到ID卡时候
{
// Show card type
//ShowCardType(str);
//Prevent conflict, return the 4 bytes Serial number of the card
status = MFRC522_Anticoll(str);
// str[0..3]: serial number of the card
// str[4]: XOR checksum of the SN.
if (status == MI_OK)
{
memcpy(serNum, str, 5);
Serial.print("ID:");
ShowCardID(serNum);
// Check people associated with card ID
unsigned char* id = serNum;
if( id[0]==0xed && id[1]==0x34 && id[2]==0xfa && id[3]==0x95 )
{
digitalWrite(Relay,HIGH); //打开继电器
Serial.println("The Host 1!");
}
else if(id[0]==0x4C && id[1]==0xB3 && id[2]==0x74 && id[3]==0x19)
{
digitalWrite(Relay,LOW); //继电器
Serial.println("The Host 2!");
}
else
{
Serial.println("Stranger!");
}
}
}
MFRC522_Halt(); //command the card into sleep mode
delay(100);
}
复制代码
所有资料51hei提供下载:
lesson38.rar
(6.67 KB, 下载次数: 82)
2018-5-4 14:22 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
cc19940410
时间:
2018-5-30 23:27
那个,我想问下为什么接入继电器的时候处于高电平状态?
作者:
tqlww
时间:
2021-12-1 08:26
请问有RFID头文件吗
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1