极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 24278|回复: 13

RFID模块能够读卡号,如何将读出的卡号存储后,再读卡时进行匹配是否相等?

[复制链接]
发表于 2012-7-31 22:00:23 | 显示全部楼层 |阅读模式
本帖最后由 cnkids 于 2012-8-1 21:30 编辑

char Str1[4];
int i=0;
const int ENPin = 2;     // the number of the EN pin
int ENState = 1;  //default EN state was HIGH

unsigned char ID[4] = {0x00,0x17,0x3E,0x41};
int val = 0;
int status = 0;
  
void setup()
{
  Serial.begin(9600);
  pinMode(ENPin, INPUT);
}
void loop()
{
  // read the state of the EN value:
  ENState = digitalRead(ENPin);

  // check if the EN is LOW,the output the data.

  while(ENState == LOW&&Serial.available() > 0)
  {     
    // read the incoming byte:
      Str1 = Serial.read();
      if(i>=3)
      {
        i=0;
        Serial.println(" ");
      }
      else
      {
        Serial.print(Str1, HEX);
        i++;
      }
  }
  i=0;

}

用的是thomas的程序,改了一些..是在不知道卡号匹配比较从哪加进去。。。求高手~
回复

使用道具 举报

发表于 2012-8-1 00:51:12 | 显示全部楼层
我这里有个实例!
  1. #include <NewSoftSerial.h>



  2. NewSoftSerial RFID(2, 3);
  3. String msg;
  4. String ID ;  //string to store allowed cards

  5. void setup()  
  6. {
  7.   Serial.begin(9600);
  8.   Serial.println("Serial Ready");

  9.   RFID.begin(9600);
  10.   Serial.println("RFID Ready");
  11. }

  12. char c;
  13. int i=1;

  14. void loop(){
  15.   
  16.   while(RFID.available()>0){
  17.     c=RFID.read();
  18.     msg += c;
  19.     Serial.println(msg);  //Uncomment to view your tag ID
  20.     Serial.println(msg.length());
  21.     }
  22.   
  23. }
复制代码
回复 支持 反对

使用道具 举报

发表于 2012-8-1 00:53:00 | 显示全部楼层
库文件。。。。。。。。。。!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-8-1 02:02:40 | 显示全部楼层
txmg 发表于 2012-8-1 00:51
我这里有个实例!#include

半夜睡不着,爬起来看看~
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-8-1 02:03:49 | 显示全部楼层
txmg 发表于 2012-8-1 00:53
库文件。。。。。。。。。。!

貌似我还没达到可以下载的要求。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-8-1 03:31:45 | 显示全部楼层
txmg 发表于 2012-8-1 00:51
我这里有个实例!#include

NewSoftSerial RFID(2, 3);
这个定义的是啥。。。
回复 支持 反对

使用道具 举报

发表于 2012-8-1 11:58:18 | 显示全部楼层
cnkids 发表于 2012-8-1 03:31
NewSoftSerial RFID(2, 3);
这个定义的是啥。。。

多使用谷歌!!http://arduino.cc/en/Reference/SoftwareSerialConstructor
回复 支持 反对

使用道具 举报

发表于 2012-8-1 11:58:46 | 显示全部楼层
cnkids 发表于 2012-8-1 02:03
貌似我还没达到可以下载的要求。。。

设置的就是注册会员。。。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-8-1 15:59:29 | 显示全部楼层
txmg 发表于 2012-8-1 11:58
多使用谷歌!!http://arduino.cc/en/Reference/SoftwareSerialConstructor

好吧,3Q~大半夜的看程序果然会昏~我再仔细研究研究
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-8-1 15:59:58 | 显示全部楼层
txmg 发表于 2012-8-1 11:58
设置的就是注册会员。。。。。

昨晚默默的去回了许多帖子才变成注册会员。。
回复 支持 反对

使用道具 举报

发表于 2013-9-6 21:26:31 | 显示全部楼层
好吧,权限不够
回复 支持 反对

使用道具 举报

发表于 2014-8-7 15:58:46 | 显示全部楼层
权限不够
回复 支持 反对

使用道具 举报

发表于 2014-8-7 17:10:56 | 显示全部楼层
txmg 发表于 2012-8-1 00:51
我这里有个实例!#include

先留着,   
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-19 01:32:24 | 显示全部楼层
myfzh 发表于 2014-8-7 15:58
权限不够

分不够?多回复几篇帖子赚点分呗
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-7 13:49 , Processed in 0.041081 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表