Advertisement
microrobotics

MFRC522 NFC RFID 13.56Mhz

May 5th, 2023
2,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. VCC 3.3V
  3. SWIM    Unconnected
  4. GND GND
  5. NRST    Unconnected
  6. VCC 3.3V
  7. TXD GPIO 16 (or any other available GPIO, except 6-11 and 34-39)
  8. RXD GPIO 17 (or any other available GPIO, except 6-11 and 34-39)
  9. GND GND
  10. */
  11.  
  12. #include <HardwareSerial.h>
  13.  
  14. // Define the HardwareSerial pins (RX, TX)
  15. HardwareSerial RFID_Serial(1); // Use UART1
  16. const int RXD_PIN = 16;
  17. const int TXD_PIN = 17;
  18.  
  19. void setup() {
  20.   // Configure the pins for UART1
  21.   RFID_Serial.begin(9600, SERIAL_8N1, RXD_PIN, TXD_PIN);
  22.  
  23.   // Open serial communications for debugging and set the baud rate:
  24.   Serial.begin(115200);
  25.   while (!Serial) {
  26.     ; // wait for serial port to connect. Needed for native USB port only
  27.   }
  28. }
  29.  
  30. void loop() {
  31.   if (RFID_Serial.available()) {
  32.     Serial.write(RFID_Serial.read());
  33.   }
  34.   if (Serial.available()) {
  35.     RFID_Serial.write(Serial.read());
  36.   }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement