当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Project 044 - Simple RFID Reader

RonWang1个月前 (12-11)电子编程101

Arduino Programming Basic -- Making an RFID Reader

Project 44 Simple RFID Reader

Arduino RFID RC522

Wiring Diagram Between RC522 and Arduino without voltage regulator

Arduino RFID RC522 Resistor

Wiring Diagram Between RC522 and Arduino with voltage regulator

As Circuit in the wiring diagram above, 1kOhM and 2kOhm pair of resistors are used to regulate 5V to 3.3V. It does not need to adjust the voltage between the Arduino pin and the MISO pin of the RC522 module. However, it is necessary to regulate the voltage between the Arduino pins and the SS, SCK, MOSI, and RST pins of the RC522 module.

// Project 44  Simple RFID Reader   Arduino-RFID-NFC

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 5

MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin(); // init SPI bus
  rfid.PCD_Init(); // init MFRC522

  Serial.println("Tap RFID/NFC Tag on reader");
}

void loop() {
  if (rfid.PICC_IsNewCardPresent()) { // new tag is available
    if (rfid.PICC_ReadCardSerial()) { // NUID has been readed
      MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
      //Serial.print("RFID/NFC Tag Type: ");
      //Serial.println(rfid.PICC_GetTypeName(piccType));

      // print NUID in Serial Monitor in the hex format
      Serial.print("UID:");
      for (int i = 0; i < rfid.uid.size; i++) {
        Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
        Serial.print(rfid.uid.uidByte[i], HEX);
      }
      Serial.println();

      rfid.PICC_HaltA(); // halt PICC
      rfid.PCD_StopCrypto1(); // stop encryption on PCD
    }
  }
}

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://parentscn.com/?id=301

标签: Arduino

相关文章

Arduino Project 017 - Shift Register 8-Bit Binary Counter

Arduino Project 017 - Shift Register 8-Bit Binary Counter

In this project, you’re going to use additional ICs (Integrated Circuits) in the form of shift regis...

Arduino Project 023C - Liquid Crystal Displays - Serial to Display

Arduino Project 023C - Liquid Crystal Displays - Serial to Display

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14...

Arduino Project 013 - Piezo Knock Sensor

Arduino Project 013 - Piezo Knock Sensor

A piezo disc works when an electric current is passed over the ceramic material in the disc, causing...

Arduino Project 004 - LED Interactive Traffic Lights

Arduino Project 004 - LED Interactive Traffic Lights

This time you are going to extend the previous project to include a set of pedestrian lights and a p...

 ​Arduino Project 048 - Human Body Infrared Detector and Relay Light

​Arduino Project 048 - Human Body Infrared Detector and Relay Light

Project 48 Human Body Infrared Detector and Relay Light/*  * Coding by Ronwang&...

Arduino UNO Mp3音乐播放代码

Arduino UNO Mp3音乐播放代码

Arduino UNO Mp3音乐播放代码今天我们将使用Arduino UNO 和SD卡制作音乐播放器。这个播放器不需要添加多余的模块,只需要SD读卡器和Arduino UNO开发板就可以播放音频文件...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。