Need help in coding

// Example sketch to read the ID from an Addicore 13.56MHz RFID tag // as found in the RFID AddiKit found at: // http://www.addicore.com/RFID-AddiKit-with-RC522-MIFARE-Module-RFID-Cards-p/126.htm

include

include

define uchar unsigned char

define uint unsigned int

//4 bytes tag serial number, the first 5 bytes for the checksum byte uchar serNumA[5];

uchar fifobytes; uchar fifoValue;

AddicoreRFID myRFID; // create AddicoreRFID object to control the RFID module

///////////////////////////////////////////////////////////////////// //set the pins ///////////////////////////////////////////////////////////////////// const int chipSelectPin = 10; //SDA pins const int NRSTPD = 5; //reset pin int sensePin=2; //the pin the FSR is attached to int ledPin=9; // the pin the LED is attached to (use one capable of PWM) int speaker=8; int LEDbrightness;

//Maximum length of the array

define MAX_LEN 16

void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps pinMode(speaker, OUTPUT); //declare the speaker as an OUTPUT pinMode(ledPin, OUTPUT); //declare the ledPin as an OUTPUT

// start the SPI library: SPI.begin(); pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin digitalWrite(chipSelectPin, LOW); // Activate the RFID reader pinMode(NRSTPD,OUTPUT); // Set digital pin 10 , Not Reset and Power-down digitalWrite(NRSTPD, HIGH);

myRFID.AddicoreRFID_Init();

} void loop() { int value=analogRead(sensePin); Serial.println(value); int pitch=map(value,0,1023,225,255); LEDbrightness=map(value,0,1023,0,255); analogWrite(ledPin,value); analogWrite(speaker,value); uchar i, tmp, checksum1; uchar status; uchar str[MAX_LEN]; uchar RC_size; uchar blockAddr; //Selection operation block address 0 to 63 String mynum = "";

str[1] = 0x4400; //Find tags, return tag type status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str); if (status == MI_OK && value>0) { Serial.println("RFID tag detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); digitalWrite(ledPin,LOW); noTone(8); } else if (status!=MI_OK && value==0) { digitalWrite(ledPin,HIGH); tone(8,pitch); }

//Anti-collision, return tag serial number 4 bytes status = myRFID.AddicoreRFID_Anticoll(str); if (status == MI_OK) { checksum1 = str[0] ^ str[1] ^ str[2] ^ str[3]; Serial.println("The tag's number is : "); //Serial.print(2); Serial.print(str[0]); Serial.print(" , "); Serial.print(str[1],BIN); Serial.print(" , "); Serial.print(str[2],BIN); Serial.print(" , "); Serial.print(str[3],BIN); Serial.print(" , "); Serial.print(str[4],BIN); Serial.print(" , "); Serial.println(checksum1,BIN);

// Should really check all pairs, but for now we'll just use the first if(str[0] == 94) //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor { Serial.print("Hello world!\n"); } else if(str[0] == 100) { //You can change this to the first byte of your tag by finding the card's ID through the Serial Monitor Serial.print("Hello User!\n"); } Serial.println(); delay(1000);

}

myRFID.AddicoreRFID_Halt(); //Command tag into hibernation

}

Can i know what is the difference between status = myRFID.AddicoreRFID_Anticoll(str); and status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);

Thank you! :)

Look at how your code is displayed in the forum. In particular, look at the sunglasses-wearing emoticon that appears next to a call to noTone(); Is that what you intended?

You didn't use code tags to post your code. It's important that you use them - if you don't, the forum software sometimes interprets sequences of characters in the code as directives to format text in some way. It won't display those sequences, and it will unexpectedly reformat the rest of the text. When that happens, and someone tries to copy your code and paste it into the IDE, it throws an error, and readers will complain that the code fails to compile.

You can learn how to use code tags by reading the sticky post, "How to use this forum - please read," shown near the top of the subject listing for most sections of the forum. Once you know how to use code tags, you can edit your post to enclose your code in code tags, and it will look just fine.

I think that you intended to say noTone(8);but I'm not sure. Working backwards from errant emoticons is time-consuming, boring, and error-prone.

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.

Also you can go and edit the TOPIC of your thread, to RFID programming help.

You may get more hits as at the moment not a lot of members are going to go to the trouble of looking at "Need help in coding", we know you do, that is why you are here.

Tom... :)

Thanks for the suggestions! :)