Keep on getting very many errors for the script and don't know how to fix them

#include <deprecated.h>
#include <MFRC522.h>
#include <MFRC522Extended.h>
#include <require_cpp11.h>

/*  
* Read a card using a mfrc522 reader on your SPI interface  
 * Pin layout should be as follows (on Arduino Uno):  
 * MOSI: Pin 11 / ICSP-4  
 * MISO: Pin 12 / ICSP-1  
 * SCK: Pin 13 / ISCP-3  
 * SS: Pin 10  
 * RST: Pin 5  
 */  
#include <SPI.h>  
#include <MFRC522.h>  
#define SS_PIN 10  
#define RST_PIN 5  
MFRC522 mfrc522(SS_PIN,RST_PIN);  
int serNum[5];  
void setup(){  
 Serial.begin(9600);  
 SPI.begin();  
do (MFRC522 _=::/(.init))();  
}  
void loop(){  
 if(MFRC522.isCard()){  
  if(MFRC522.readCardSerial()) {  
   Serial.print(MFRC522.serNum[0],DEC);  
   Serial.print(" ");  
   Serial.print(MFRC522.serNum[1],DEC);  
   Serial.print(" ");  
   Serial.print(MFRC522.serNum[2],DEC);  
   Serial.print(" ");  
   Serial.print(MFRC522.serNum[3],DEC);  
   Serial.print(" ");  
   Serial.print(MFRC522.serNum[4],DEC);  
   Serial.println("");  
  }  
 }  
once done MFRC522 _=::(.halt)();  
}

I have this script and I have questions about why it keeps on having so many errors.
Please help, I am a newbie.

What errors do you get? We answer these things while on phones and away from out computers, so knowing the error often lets us help when we otherwise couldnt - and besides, since we're helping you for free, you should make it easy for us.

Also, use code tags when posting code.

And, what arduino board?

 do (MFRC522 _=::/(.init))();

That looks like that got badly mangled in transmission. I can't even guess what was intended.

once done MFRC522 _=::(.halt)();

Or that.

Can you please go back and edit your post to put the code in code tags and add at least some of the error messages?

That is not how the do keyword works in C. It may work like that in some other programming language, but it sure isn't valid C.

that 'once done' bit is also something that may be valid syntax in some programming language that isn't the one you're using here.

 /*  
* Read a card using a mfrc522 reader on your SPI interface  
 * Pin layout should be as follows (on Arduino Uno):  
 * MOSI: Pin 11 / ICSP-4  
 * MISO: Pin 12 / ICSP-1  
 * SCK: Pin 13 / ISCP-3  
 * SS: Pin 10  
 * RST: Pin 5  
 */  
#include <SPI.h>  
#include <RFID.h>  
#define SS_PIN 10  
#define RST_PIN 5  
RFID rfid(SS_PIN,RST_PIN);  
int serNum[5];  
void setup(){  
 Serial.begin(9600);  
 SPI.begin();  
 rfid.init();  
}  
void loop(){  
 if(rfid.isCard()){  
  if(rfid.readCardSerial()) {  
   Serial.print(rfid.serNum[0],DEC);  
   Serial.print(" ");  
   Serial.print(rfid.serNum[1],DEC);  
   Serial.print(" ");  
   Serial.print(rfid.serNum[2],DEC);  
   Serial.print(" ");  
   Serial.print(rfid.serNum[3],DEC);  
   Serial.print(" ");  
   Serial.print(rfid.serNum[4],DEC);  
   Serial.println("");  
  }  
 }  
 rfid.halt();  
}

This is my original script.
In the rfid.halt(); line I always get the error expected unqualified-id before ‘.’ token, and don’t know what to put there.

In the error window at the bottom, scroll up to find the first error. Usually fixing that will fix many other error messages.

I am guessing the RFID library is not installed properly.

#include <SeeedRFID.h>

/*  
* Read a card using a mfrc522 reader on your SPI interface  
 * Pin layout should be as follows (on Arduino Uno):  
 * MOSI: Pin 11 / ICSP-4  
 * MISO: Pin 12 / ICSP-1  
 * SCK: Pin 13 / ISCP-3  
 * SS: Pin 10  
 * RST: Pin 5  
 */  
#include <SPI.h>  
#include <SeeedRFID.h>  
#define SS_PIN 10  
#define RST_PIN 5  
SeeedRFID rfid(SS_PIN,RST_PIN);  
int serNum[5];  
void setup(){  
 Serial.begin(9600);  
 SPI.begin();  
 SeeedRFID.init();  
}  
void loop(){  
 if(SeeedRFID.isCard()){  
  if(SeeedRFID.readCardSerial()) {  
   Serial.print(SeeedRFID.serNum[0],DEC);  
   Serial.print(" ");  
   Serial.print(SeeedRFID.serNum[1],DEC);  
   Serial.print(" ");  
   Serial.print(SeeedRFID.serNum[2],DEC);  
   Serial.print(" ");  
   Serial.print(SeeedRFID.serNum[3],DEC);  
   Serial.print(" ");  
   Serial.print(SeeedRFID.serNum[4],DEC);  
   Serial.println("");  
  }  
 }  
 SeeedRFID.halt();  
}

I uploaded a new rfid library and used it in the script but it gave me the same error in the line
SeeedRFID.init();

In reply #2 you were asked to use code tags. Read How to use this forum, point 7.

In reply #2 you were also asked to post at least some of the error messages. Why don't you do that? Some vague description of the error will not help us to help you. There is more in the output window than just two lines; copy all of them and paste them here.

Please provide links to the libraries that you used. Usually libraries come with examples; do the examples compile?

 SPI.begin();  
  rfid.init();

etc, etc

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

What model Arduino are you coding for?

Thanks… Tom… :slight_smile:

I am using the arduino uno

PLEASE
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Have you tried the sample code that came with the library to check if you can get a successful compile?

The seed library is for a serial comms to RFID reader not SPI.

Thanks.. Tom.. :slight_smile:

Hi,
Example code from MFRC library.

/**
 * ----------------------------------------------------------------------------
 * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid
 * for further details and other examples.
 *
 * NOTE: The library file MFRC522.h has a lot of useful info. Please read it.
 *
 * Released into the public domain.
 * ----------------------------------------------------------------------------
 * This sample shows how to read and write data blocks on a MIFARE Classic PICC
 * (= card/tag).
 *
 * BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7).
 *
 *
 * Typical pin layout used:
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno/101       Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS      SDA(SS)      10            53        D10        10               10
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
 *
 */

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

constexpr uint8_t RST_PIN = 9;     // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 10;     // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

MFRC522::MIFARE_Key key;

/**
 * Initialize.
 */
void setup() {
    Serial.begin(9600); // Initialize serial communications with the PC
    while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
    SPI.begin();        // Init SPI bus
    mfrc522.PCD_Init(); // Init MFRC522 card

    // Prepare the key (used both as key A and as key B)
    // using FFFFFFFFFFFFh which is the default at chip delivery from the factory
    for (byte i = 0; i < 6; i++) {
        key.keyByte[i] = 0xFF;
    }

    Serial.println(F("Scan a MIFARE Classic PICC to demonstrate read and write."));
    Serial.print(F("Using key (for A and B):"));
    dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE);
    Serial.println();

    Serial.println(F("BEWARE: Data will be written to the PICC, in sector #1"));
}

/**
 * Main loop.
 */
void loop() {
    // Look for new cards
    if ( ! mfrc522.PICC_IsNewCardPresent())
        return;

    // Select one of the cards
    if ( ! mfrc522.PICC_ReadCardSerial())
        return;

    // Show some details of the PICC (that is: the tag/card)
    Serial.print(F("Card UID:"));
    dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
    Serial.println();
    Serial.print(F("PICC type: "));
    MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
    Serial.println(mfrc522.PICC_GetTypeName(piccType));

    // Check for compatibility
    if (    piccType != MFRC522::PICC_TYPE_MIFARE_MINI
        &&  piccType != MFRC522::PICC_TYPE_MIFARE_1K
        &&  piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
        Serial.println(F("This sample only works with MIFARE Classic cards."));
        return;
    }

    // In this sample we use the second sector,
    // that is: sector #1, covering block #4 up to and including block #7
    byte sector         = 1;
    byte blockAddr      = 4;
    byte dataBlock[]    = {
        0x01, 0x02, 0x03, 0x04, //  1,  2,   3,  4,
        0x05, 0x06, 0x07, 0x08, //  5,  6,   7,  8,
        0x09, 0x0a, 0xff, 0x0b, //  9, 10, 255, 11,
        0x0c, 0x0d, 0x0e, 0x0f  // 12, 13, 14, 15
    };
    byte trailerBlock   = 7;
    MFRC522::StatusCode status;
    byte buffer[18];
    byte size = sizeof(buffer);

    // Authenticate using key A
    Serial.println(F("Authenticating using key A..."));
    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("PCD_Authenticate() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
        return;
    }

    // Show the whole sector as it currently is
    Serial.println(F("Current data in sector:"));
    mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
    Serial.println();

    // Read data from the block
    Serial.print(F("Reading data from block ")); Serial.print(blockAddr);
    Serial.println(F(" ..."));
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size);
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("MIFARE_Read() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
    }
    Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":"));
    dump_byte_array(buffer, 16); Serial.println();
    Serial.println();

    // Authenticate using key B
    Serial.println(F("Authenticating again using key B..."));
    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid));
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("PCD_Authenticate() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
        return;
    }

    // Write data to the block
    Serial.print(F("Writing data into block ")); Serial.print(blockAddr);
    Serial.println(F(" ..."));
    dump_byte_array(dataBlock, 16); Serial.println();
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Write(blockAddr, dataBlock, 16);
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("MIFARE_Write() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
    }
    Serial.println();

    // Read data from the block (again, should now be what we have written)
    Serial.print(F("Reading data from block ")); Serial.print(blockAddr);
    Serial.println(F(" ..."));
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size);
    if (status != MFRC522::STATUS_OK) {
        Serial.print(F("MIFARE_Read() failed: "));
        Serial.println(mfrc522.GetStatusCodeName(status));
    }
    Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":"));
    dump_byte_array(buffer, 16); Serial.println();

    // Check that data in block is what we have written
    // by counting the number of bytes that are equal
    Serial.println(F("Checking result..."));
    byte count = 0;
    for (byte i = 0; i < 16; i++) {
        // Compare buffer (= what we've read) with dataBlock (= what we've written)
        if (buffer[i] == dataBlock[i])
            count++;
    }
    Serial.print(F("Number of bytes that match = ")); Serial.println(count);
    if (count == 16) {
        Serial.println(F("Success :-)"));
    } else {
        Serial.println(F("Failure, no match :-("));
        Serial.println(F("  perhaps the write didn't work properly..."));
    }
    Serial.println();

    // Dump the sector data
    Serial.println(F("Current data in sector:"));
    mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
    Serial.println();

    // Halt PICC
    mfrc522.PICC_HaltA();
    // Stop encryption on PCD
    mfrc522.PCD_StopCrypto1();
}

/**
 * Helper routine to dump a byte array as hex values to Serial.
 */
void dump_byte_array(byte *buffer, byte bufferSize) {
    for (byte i = 0; i < bufferSize; i++) {
        Serial.print(buffer[i] < 0x10 ? " 0" : " ");
        Serial.print(buffer[i], HEX);
    }
}

It compiles for me , Win7, 1.8.5 IDE, for UNO.

By the way, I started using some examples from the MFRC522 library, and they didn't work, and then I rewired my sensor and it turns out that the sensor wasn't wired properly to the board, but now it works just fine. Thanks for the help, guys!

DrAzzy:
That is not how the do keyword works in C. It may work like that in some other programming language, but it sure isn't valid C.

that 'once done' bit is also something that may be valid syntax in some programming language that isn't the one you're using here.

Yeah true. I didn't even know there was a 'do' for C. I think there is one for 'fortran'.