Hello
I make connected the RFID reader with Arduino Nano. The Arduino is connected with the computer via USB. The Arduino contains the code that makes the RFID reader scan every half-second to make sure there is a card to read.
Arduino sketch
-------[ // This sketch is made to read an RFID tag every second, if present, and send that info to the serial COM port.
// In this example, I used a arduino Uno and a RC-522 RFID reader operating at 13.56 MGHz.
// Make sure you download and install the SPI & MFRC522 arduino libraries before running this script.
//Created by SdT @ MNI 07/2017
#include <SPI.h> // Make sure you have the SPI livrary to enable communication
#include <MFRC522.h> // This includes the library for the specific reader used in this test, the RFID-RC522
#define RST_PIN 9 // Define the reset pin on the arduino
#define SS_PIN 10 // Define the sda pin on the arduino
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup()
{
Serial.begin(9600); // Initialize serial communications with the PC at 9600 baud rate
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Initialize SPI communication between arduino and rfid module
mfrc522.PCD_Init(); // Init MFRC522 RFID card
delay(500);
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { // Look for new cards, and select one if present
delay(1000); // Set this time parameter to adjust the frequency of RFID scanning
return;
}
for (byte i = 0; i < mfrc522.uid.size; i++) // Read, format and print the unique tag identifier (UID)
{
Serial.print(mfrc522.uid.uidByte < 0x10 ? " 0" : " ");
_ Serial.print(mfrc522.uid.uidByte*, HEX); //HEX or DEC or OCT or BIN*_
* }*
* Serial.println();*
}
]-----------
At the computer I connect the Matlab with the Arduino where the Matlab scans the Arduino. The card number will be read in the Matlab. The problem starts when I want to send a command from Matlab to the Arduino to run the LED. Where execution is delayed and an error message (Updating server code on board Nano3 (COM5). Please wait.) appears. After that the LED is turned on, but the code in the Arduino stops working and does not read the RFID card even if the Arduino is turned off and turned on again. After that I delete the code on the Arduino and then reload it again to get back to work