• Mixly智能门禁(物联网)


    智能门禁
    arduino rc522读卡器  sg90舵机 校园卡
    我的校园卡号识别为 30fcb4a8d

     

     

     

    
    #include <RFID.h>
    #include <SPI.h>
    #include <Servo.h>

    RFID rfid(10,5);
    unsigned char RC_size;
    unsigned char blockAddr;        //选择操作的块地址0~63
    unsigned char i,tmp;
    unsigned char status;
    unsigned char str[MAX_LEN];
    Servo servo_5;
    char * card[]={"30fcb4a8d","10aab4afb","30fcb4a83"};

    char * name[]={"wu","liu","lu"};

    String rc;

    String RFID_readcardnum() {

     rfid.readCardSerial();
      String stringserNum=String(rfid.serNum[0], HEX)+String(rfid.serNum[1], HEX)+String(rfid.serNum[2], HEX)+String(rfid.serNum[3], HEX)+String(rfid.serNum[4], HEX);
          //选卡,返回卡容量(锁定卡片,防止多次读写)
          rfid.selectTag(rfid.serNum);
      return stringserNum;
    }

    //4字节卡序列号,第5字节为校验字节
    //新扇区A密码,16个扇区,每个扇区密码6Byte
    unsigned char sectorNewKeyA[16][16] = {
     {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
     {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xff,0x07,0x80,0x69, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
     {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xff,0x07,0x80,0x69, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},};
    unsigned char serNum[5];
    //写卡数据
    //原扇区A密码,16个扇区,每个扇区密码6Byte
    unsigned char sectorKeyA[16][16] = {
     {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
     {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
     {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},};

    void setup(){
      rc = "";
      Serial.begin(9600);
      SPI.begin();
      rfid.init();
      servo_5.attach(5);
      Serial.begin(9600);
    }

    void loop(){
      if ( rfid.isCard()  ) {
        rc = RFID_readcardnum();
        for (int i = (1); i <= (sizeof(card)/sizeof(card[0])); i = i + (1)) {
          if (rc == card[(int)(i - 1)]) {
            servo_5.write(90);
            delay(3000);
            servo_5.write(0);
            delay(0);

          }
        }
        Serial.println(RFID_readcardnum());
      }

    }
  • 相关阅读:
    数据查询语言DQL 与 内置函数(聚合函数)
    数据操作语言DML与运算符
    解决Nginx重启时提示nginx: [emerg] bind() to 0.0.0.0:80错误
    Linux 重启nginx
    一群猴子排成一圈,按1,2,...,n依次编号
    阿里云云盾服务证书免费CA证书申请与配置 (原)
    Linux 配置文件
    php $_FILES上传失败 error返回值说明
    Ecshop 表结构 字段说明
    JS 笔记~
  • 原文地址:https://www.cnblogs.com/fafafa123/p/11739578.html
Copyright © 2020-2023  润新知