Thursday, May 20, 2021

Arduino RFID Project

                                       RFID 
        

HARDWARE REQUIRED :-- Click here to buy
1. Electrobot (UNO R3) Board
2. Usb cable
3. RFID ID Round tag
4. RFID ID Card
5. LCD 1602
6. 10K ohm potentiometer
7. NPN Transistor
8. 1k ohm resistor
9. passive buzzer
10. Bateery holder
11. Breadboard
12. Several jumpher wire

PRINCIPLE:--
RFID technology is used for a wide variety of applications including access control, package identification, warehouse stock control, point-of-sale scanning, retail antitheft systems, toll-road passes, surgical instrument inventory,and evenforidentifying individualsheets ofpaperplacedonadesk. RFID tags are embedded in name badges, shipping labels, library books, product tags and boxes; installed in aircraft; hidden inside car keys; and implanted under the skin of animals or even people. RFID systems work on a wide range of frequencies, have a variety of modulation and encoding schemes, and vary from low-power passive devices with range of only a few millimeters to active systems that work for hundreds of kilometers. However, all RFID systems have the same basic two-part architecture: a reader and a transponder.The reader is an active device that sends out a signal and listens for responses, and the transponder (the part generally called the “tag”) detects the signal from a reader and automatically sends back a response containing its identity code.
Different types of RFID tags fall into one of three broad categories: active,passive, and battery-assisted passive. Active tags are physically large because they require their own power supply such as a battery. They can also have a very long range because the availability of local power allows them to send high-powered responses that can travel from tens of meters to hundreds of kilometers. An active tag is essentially a combination of a radio receiver to detect the challenge, some logic to formulate a response, and a radio transmitter to send back the response. They can even have the challenge and response signals operate on totally different frequencies. The downsides are the size of the tag, a high manufacturing cost due to the number of parts required, and the reliance on a battery that will go flat eventually. Passive tags can be much smaller and cheaper than active tags because they don‟t require a local power supply and have much simpler circuitry. Instead of supplying their own power, they leach all the power they need from the signal sent by the reader. Early passive tags operated on the “Wiegand effect,” which uses a specially formed wire to convert received electromagnetic energy into radio-wave pulses. Some early passive RFID tags actually consisted of nothing more than a number of very carefully formed wires made from a combination of cobalt, iron, and vanadium, with no other parts at all. Modern passive tags use a clever technique that uses current induced in their antenna coil to power the electronics required to generate the response. The response is then sent by modulating the reader‟s own field, and the reader detects the modulation as a tiny fluctuation in the voltage across the transmitter coil. The result is that passive tags can be incredibly small and extremely inexpensive: the antenna can be a simple piece of metal foil, and the microchips are produced in such large quantities that a complete RFID-enabled product label could cost only a few cents and be no thickerthan a normal paper label. Passive tags can theoretically last indefinitely because they don‟t contain a battery to go flat, but their disadvantage is a very short operational range due to the requirement to leach power from the reader‟s signal, and lack of an actively poweredtransmittertosendbacktheresponse. Passive tags typically operate over a range of a few millimeters up to a few meters. Tags can also have a variety of different modulation schemes, including AM, PSK, and ASK, and different encoding systems. With so many incompatiblevariations, it‟s sometimes hard to know if specific tags and readers are compatible. Generally speaking, each type of tag will only function on one specific frequency, modulation scheme, and communications protocol. Readers, on the other hand, are far more flexible and will often support a range of modulation schemes and comms protocols, but are usually still limited to just one frequency due to the tuning requirements of the coil. Apart from the specific requirements for communicating with them, tags can also have a number of different features. The most common passive tags simply contain a hardcoded unique serial number and when interrogated by a reader they automatically respond with their ID code. Most tags are read-only so you can‟t change the value they return, but some types of tags are read/write and contain a tiny amount of rewritable storage so you can insert data into them using a reader and retrieve it later. However, most uses of RFID don‟t rely on any storage within the tag, and merely use the ID code of the tag as a reference numberto look up information about it in an external database or other system. RFID tags are produced in a wide variety of physical form factors to suit different deployment requirements.Themostcommonlyseenformfactorisa flat plastic cardthe same sizeas acreditcard,often usedas anaccess control pass to gain access to office buildings or other secure areas. The most common form by sheer number produced, even though you might not notice them,isRFID-enabledstickersthatarecommonly placedonboxes,packages, andproducts.Keyfobtagsarealsoquitecommon,designed tobeattached to a keyring so they‟re always handy for operating access control systems.




connections :--

coding :--
#include <SPI.h>
#include <LiquidCrystal.h>
 
#define uchar unsigned char
#define uint unsigned int
 
//data array maxium length
#define MAX_LEN 16
 

const int chipSelectPin = 10;
const int NRSTPD = 9;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);   
int buzzerpin=8;
 
 
//MF522 command bits
#define PCD_IDLE 0x00 //NO action; cancel current commands
#define PCD_AUTHENT 0x0E //verify password key
#define PCD_RECEIVE 0x08 //receive data
#define PCD_TRANSMIT 0x04 //send data
#define PCD_TRANSCEIVE 0x0C //send and receive data
#define PCD_RESETPHASE 0x0F //reset
#define PCD_CALCCRC 0x03 //CRC check and caculation
 
//Mifare_One card command bits
#define PICC_REQIDL 0x26 //Search the cards that not into sleep mode in the antenna area 
#define PICC_REQALL 0x52 //Search all the cards in the antenna area
#define PICC_ANTICOLL 0x93 //prevent conflict
#define PICC_SElECTTAG 0x93 //select card
#define PICC_AUTHENT1A 0x60 //verify A password key
#define PICC_AUTHENT1B 0x61 //verify B password key
#define PICC_READ 0x30 //read 
#define PICC_WRITE 0xA0 //write
#define PICC_DECREMENT 0xC0 //deduct value
#define PICC_INCREMENT 0xC1 //charge up value
#define PICC_RESTORE 0xC2 //Restore data into buffer
#define PICC_TRANSFER 0xB0 //Save data into buffer
#define PICC_HALT 0x50 //sleep mode
 
 
//THe mistake code that return when communicate with MF522
#define MI_OK 0
#define MI_NOTAGERR 1
#define MI_ERR 2
 
 
//------------------MFRC522 register ---------------
//Page 0:Command and Status
#define Reserved00 0x00 
#define CommandReg 0x01 
#define CommIEnReg 0x02 
#define DivlEnReg 0x03 
#define CommIrqReg 0x04 
#define DivIrqReg 0x05
#define ErrorReg 0x06 
#define Status1Reg 0x07 
#define Status2Reg 0x08 
#define FIFODataReg 0x09
#define FIFOLevelReg 0x0A
#define WaterLevelReg 0x0B
#define ControlReg 0x0C
#define BitFramingReg 0x0D
#define CollReg 0x0E
#define Reserved01 0x0F
//Page 1:Command 
#define Reserved10 0x10
#define ModeReg 0x11
#define TxModeReg 0x12
#define RxModeReg 0x13
#define TxControlReg 0x14
#define TxAutoReg 0x15
#define TxSelReg 0x16
#define RxSelReg 0x17
#define RxThresholdReg 0x18
#define DemodReg 0x19
#define Reserved11 0x1A
#define Reserved12 0x1B
#define MifareReg 0x1C
#define Reserved13 0x1D
#define Reserved14 0x1E
#define SerialSpeedReg 0x1F
//Page 2:CFG 
#define Reserved20 0x20 
#define CRCResultRegM 0x21
#define CRCResultRegL 0x22
#define Reserved21 0x23
#define ModWidthReg 0x24
#define Reserved22 0x25
#define RFCfgReg 0x26
#define GsNReg 0x27
#define CWGsPReg 0x28
#define ModGsPReg 0x29
#define TModeReg 0x2A
#define TPrescalerReg 0x2B
#define TReloadRegH 0x2C
#define TReloadRegL 0x2D
#define TCounterValueRegH 0x2E
#define TCounterValueRegL 0x2F
//Page 3:TestRegister 
#define Reserved30 0x30
#define TestSel1Reg 0x31
#define TestSel2Reg 0x32
#define TestPinEnReg 0x33
#define TestPinValueReg 0x34
#define TestBusReg 0x35
#define AutoTestReg 0x36
#define VersionReg 0x37
#define AnalogTestReg 0x38
#define TestDAC1Reg 0x39 
#define TestDAC2Reg 0x3A 
#define TestADCReg 0x3B 
#define Reserved31 0x3C 
#define Reserved32 0x3D 
#define Reserved33 0x3E 
#define Reserved34 0x3F
//-----------------------------------------------
 
//4 bytes Serial number of card, the 5 bytes is verfiy bytes
uchar serNum[5];
 
 
void setup() 
{ 
    Serial.begin(57600); 
     
    SPI.begin();
    lcd.begin(16, 2);    // set up the LCD's number of columns and rows: 
    lcd.clear();         //Clears the LCD screen and positions the cursor in the upper-left corner 
    pinMode(buzzerpin,OUTPUT); 
    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 5 , Not Reset and Power-down
    
    MFRC522_Init(); 
}
 
 
void loop()
{
 
    uchar status;
    uchar str[MAX_LEN];
 
    lcd.setCursor(0, 0); // set the cursor to column 0, line 0
    lcd.print("adeeptID        ");// Print a message of "Temp: "to the LCD.

    // Search card, return card types
    status = MFRC522_Request(PICC_REQIDL, str); 
    if (status != MI_OK)
    {
        return;
    }
     
     
    // Show card type
    ShowCardType(str);
     
    //Prevent conflict, return the 4 bytes Serial number of the card
    status = MFRC522_Anticoll(str);
     
    // str[0..3]: serial number of the card
    // str[4]: XOR checksum of the SN.
    if (status == MI_OK)
    {
        Serial.print("The card's number is: ");
        memcpy(serNum, str, 5);
        ShowCardID(serNum);
     
        // Check people associated with card ID
        uchar* id = serNum;
        lcd.setCursor(8, 0);
        int lcdid=4;
        for(int i=0; i<lcdid; i++){
            lcd.print(0x0F & (id[i]>>4), HEX);
            lcd.print(0x0F & id[i],HEX);
        }
        if( id[0]==0x14 && id[1]==0x68 && id[2]==0x09 && id[3]==0x6F ) {
            Serial.println("Hello vishuu!     ");
            lcd.setCursor(0, 1); // set the cursor to column 0, line 0
            lcd.print("  Hello vishuu!   ");// Print a message of "Temp: "to the LCD.
        } else if(id[0]==0x03 && id[1]==0xA2 && id[2]==0x67 && id[3]==0x00) {
            Serial.println("Hello vishu!      ");
            lcd.setCursor(0, 1); // set the cursor to column 0, line 0
            lcd.print("   Hello vishuu!   ");// Print a message of "Temp: "to the LCD.
        }else{
            Serial.println("Hello frnds");
            lcd.setCursor(0, 1); // set the cursor to column 0, line 0
            lcd.print("Hello frnds!");// Print a message of "Temp: "to the LCD.
        }
      //   lcd.print(id[0],HEX);// Print a centigrade temperature to the LCD.
      //   lcd.print(id[1],HEX);// Print a centigrade temperature to the LCD.
      //   lcd.print(id[2],HEX);// Print a centigrade temperature to the LCD.
      //   lcd.print(id[3],HEX);// Print a centigrade temperature to the LCD.
    }
    
    MFRC522_Halt(); //command the card into sleep mode 
     for(int n=1;n<100;n++){
                digitalWrite(buzzerpin, HIGH);
                delayMicroseconds(500);
                digitalWrite(buzzerpin, LOW);    
            }
     delay(2000);
}
 
/*
 * Function:ShowCardID
 * Description:Show Card ID
 * Input parameter:ID string
 * Return:Null
 */
void ShowCardID(uchar *id)
{
    int IDlen=4;
    for(int i=0; i<IDlen; i++){
        Serial.print(0x0F & (id[i]>>4), HEX);
        Serial.print(0x0F & id[i],HEX);
    }
    Serial.println("");
}
 
/*
 * Function:ShowCardType
 * Description:Show Card type
 * Input parameter:Type string
 * Return:Null
 */
void ShowCardType(uchar* type)
{
    Serial.print("Card type: ");
    if(type[0]==0x04&&type[1]==0x00) 
        Serial.println("MFOne-S50");
    else if(type[0]==0x02&&type[1]==0x00)
        Serial.println("MFOne-S70");
    else if(type[0]==0x44&&type[1]==0x00)
        Serial.println("MF-UltraLight");
    else if(type[0]==0x08&&type[1]==0x00)
        Serial.println("MF-Pro");
    else if(type[0]==0x44&&type[1]==0x03)
        Serial.println("MF Desire");
    else
        Serial.println("Unknown");
}
 
/*
 * Function:Write_MFRC5200
 * Description:write a byte data into one register of MR RC522
 * Input parameter:addr--register address;val--the value that need to write in
 * Return:Null
 */
void Write_MFRC522(uchar addr, uchar val)
{
    digitalWrite(chipSelectPin, LOW);
 
    //address format:0XXXXXX0
    SPI.transfer((addr<<1)&0x7E); 
    SPI.transfer(val);
     
    digitalWrite(chipSelectPin, HIGH);
}
 
 
/*
 * Function:Read_MFRC522
 * Description:read a byte data into one register of MR RC522
 * Input parameter:addr--register address
 * Return:return the read value
 */
uchar Read_MFRC522(uchar addr)
{
    uchar val;
 
    digitalWrite(chipSelectPin, LOW);
 
    //address format:1XXXXXX0
    SPI.transfer(((addr<<1)&0x7E) | 0x80); 
    val =SPI.transfer(0x00);
     
    digitalWrite(chipSelectPin, HIGH);
     
    return val; 
}
 
/*
 * Function:SetBitMask
 * Description:set RC522 register bit
 * Input parameter:reg--register address;mask--value
 * Return:null
 */
void SetBitMask(uchar reg, uchar mask) 
{
    uchar tmp;
    tmp = Read_MFRC522(reg);
    Write_MFRC522(reg, tmp | mask); // set bit mask
}
 
 
/*
 * Function:ClearBitMask
 * Description:clear RC522 register bit
 * Input parameter:reg--register address;mask--value
 * Return:null
 */
void ClearBitMask(uchar reg, uchar mask) 
{
    uchar tmp;
    tmp = Read_MFRC522(reg);
    Write_MFRC522(reg, tmp & (~mask)); // clear bit mask
} 
 
 
/*
 * Function:AntennaOn
 * Description:Turn on antenna, every time turn on or shut down antenna need at least 1ms delay
 * Input parameter:null
 * Return:null
 */
void AntennaOn(void)
{
    uchar temp;
 
    temp = Read_MFRC522(TxControlReg);
    if (!(temp & 0x03))
    {
        SetBitMask(TxControlReg, 0x03);
    }
}
 
 
/*
 * Function:AntennaOff
 * Description:Turn off antenna, every time turn on or shut down antenna need at least 1ms delay
 * Input parameter:null
 * Return:null
 */
void AntennaOff(void)
{
    ClearBitMask(TxControlReg, 0x03);
}
 
 
/*
 * Function:ResetMFRC522
 * Description: reset RC522
 * Input parameter:null
 * Return:null
 */
void MFRC522_Reset(void)
{
    Write_MFRC522(CommandReg, PCD_RESETPHASE);
}
 
 
/*
 * Function:InitMFRC522
 * Description:initilize RC522
 * Input parameter:null
 * Return:null
 */
void MFRC522_Init(void)
{
    digitalWrite(NRSTPD,HIGH);
 
    MFRC522_Reset();
          
    //Timer: TPrescaler*TreloadVal/6.78MHz = 24ms
    Write_MFRC522(TModeReg, 0x8D); //Tauto=1; f(Timer) = 6.78MHz/TPreScaler
    Write_MFRC522(TPrescalerReg, 0x3E); //TModeReg[3..0] + TPrescalerReg
    Write_MFRC522(TReloadRegL, 30); 
    Write_MFRC522(TReloadRegH, 0);
     
    Write_MFRC522(TxAutoReg, 0x40); //100%ASK
    Write_MFRC522(ModeReg, 0x3D); //CRC initilizate value 0x6363 ???
 
    //ClearBitMask(Status2Reg, 0x08); //MFCrypto1On=0
    //Write_MFRC522(RxSelReg, 0x86); //RxWait = RxSelReg[5..0]
    //Write_MFRC522(RFCfgReg, 0x7F); //RxGain = 48dB
 
    AntennaOn(); //turn on antenna
}
 
 
/*
 * Function:MFRC522_Request
 * Description:Searching card, read card type
 * Input parameter:reqMode--search methods,
 * TagType--return card types
 * 0x4400 = Mifare_UltraLight
 * 0x0400 = Mifare_One(S50)
 * 0x0200 = Mifare_One(S70)
 * 0x0800 = Mifare_Pro(X)
 * 0x4403 = Mifare_DESFire
 * return:return MI_OK if successed
 */
uchar MFRC522_Request(uchar reqMode, uchar *TagType)
{
    uchar status; 
    uint backBits; //the data bits that received
 
    Write_MFRC522(BitFramingReg, 0x07); //TxLastBists = BitFramingReg[2..0] ???
     
    TagType[0] = reqMode;
    status = MFRC522_ToCard(PCD_TRANSCEIVE, TagType, 1, TagType, &backBits);
 
    if ((status != MI_OK) || (backBits != 0x10))
    { 
        status = MI_ERR;
    }
    
    return status;
}
 
 
/*
 * Function:MFRC522_ToCard
 * Description:communicate between RC522 and ISO14443
 * Input parameter:command--MF522 command bits
 * sendData--send data to card via rc522
 * sendLen--send data length 
 * backData--the return data from card
 * backLen--the length of return data
 * return:return MI_OK if successed
 */
uchar MFRC522_ToCard(uchar command, uchar *sendData, uchar sendLen, uchar *backData, uint *backLen)
{
    uchar status = MI_ERR;
    uchar irqEn = 0x00;
    uchar waitIRq = 0x00;
    uchar lastBits;
    uchar n;
    uint i;
 
    switch (command)
    {
        case PCD_AUTHENT: //verify card password
        {
            irqEn = 0x12;
            waitIRq = 0x10;
            break;
        }
        case PCD_TRANSCEIVE: //send data in the FIFO
        {
            irqEn = 0x77;
            waitIRq = 0x30;
            break;
        }
        default:
            break;
    }
    
    Write_MFRC522(CommIEnReg, irqEn|0x80); //Allow interruption
    ClearBitMask(CommIrqReg, 0x80); //Clear all the interrupt bits
    SetBitMask(FIFOLevelReg, 0x80); //FlushBuffer=1, FIFO initilizate
     
    Write_MFRC522(CommandReg, PCD_IDLE); //NO action;cancel current command ???
 
    //write data into FIFO
    for (i=0; i<sendLen; i++)
    { 
        Write_MFRC522(FIFODataReg, sendData[i]); 
    }
 
    //procceed it
    Write_MFRC522(CommandReg, command);
    if (command == PCD_TRANSCEIVE)
    { 
        SetBitMask(BitFramingReg, 0x80); //StartSend=1,transmission of data starts 
    } 
     
    //waite receive data is finished
    i = 2000; //i should adjust according the clock, the maxium the waiting time should be 25 ms???
    do
    {
        //CommIrqReg[7..0]
        //Set1 TxIRq RxIRq IdleIRq HiAlerIRq LoAlertIRq ErrIRq TimerIRq
        n = Read_MFRC522(CommIrqReg);
        i--;
    }
    while ((i!=0) && !(n&0x01) && !(n&waitIRq));
 
    ClearBitMask(BitFramingReg, 0x80); //StartSend=0
     
    if (i != 0)
    { 
        if(!(Read_MFRC522(ErrorReg) & 0x1B)) //BufferOvfl Collerr CRCErr ProtecolErr
        {
            status = MI_OK;
            if (n & irqEn & 0x01)
            { 
                status = MI_NOTAGERR; //?? 
            }
             
            if (command == PCD_TRANSCEIVE)
            {
                n = Read_MFRC522(FIFOLevelReg);
                lastBits = Read_MFRC522(ControlReg) & 0x07;
                if (lastBits)
                { 
                    *backLen = (n-1)*8 + lastBits; 
                }
                else
                { 
                    *backLen = n*8; 
                }
                 
                if (n == 0)
                { 
                    n = 1; 
                }
                if (n > MAX_LEN)
                { 
                    n = MAX_LEN; 
                }
                 
                //read the data from FIFO
                for (i=0; i<n; i++)
                { 
                    backData[i] = Read_MFRC522(FIFODataReg); 
                }
            }
        }
        else
        { 
            status = MI_ERR; 
        }
         
    }
     
    //SetBitMask(ControlReg,0x80); //timer stops
    //Write_MFRC522(CommandReg, PCD_IDLE); 
 
    return status;
}
 
 
/*
 * Function:MFRC522_Anticoll
 * Description:Prevent conflict, read the card serial number 
 * Input parameter:serNum--return the 4 bytes card serial number, the 5th byte is recheck byte
 * return:return MI_OK if successed
 */
uchar MFRC522_Anticoll(uchar *serNum)
{
    uchar status;
    uchar i;
    uchar serNumCheck=0;
    uint unLen;
     
    //ClearBitMask(Status2Reg, 0x08); //strSensclear
    //ClearBitMask(CollReg,0x80); //ValuesAfterColl
    Write_MFRC522(BitFramingReg, 0x00); //TxLastBists = BitFramingReg[2..0]
  
    serNum[0] = PICC_ANTICOLL;
    serNum[1] = 0x20;
    status = MFRC522_ToCard(PCD_TRANSCEIVE, serNum, 2, serNum, &unLen);
 
    if (status == MI_OK)
    {
        //Verify card serial number
        for (i=0; i<4; i++)
        { 
            serNumCheck ^= serNum[i];
        }
        if (serNumCheck != serNum[i])
        { 
            status = MI_ERR; 
        }
    }
 
    //SetBitMask(CollReg, 0x80); //ValuesAfterColl=1
 
    return status;
} 
 
 
/*
 * Function:CalulateCRC
 * Description:Use MF522 to caculate CRC
 * Input parameter:pIndata--the CRC data need to be read,len--data length,pOutData-- the caculated result of CRC
 * return:Null
 */
void CalulateCRC(uchar *pIndata, uchar len, uchar *pOutData)
{
    uchar i, n;
 
    ClearBitMask(DivIrqReg, 0x04); //CRCIrq = 0
    SetBitMask(FIFOLevelReg, 0x80); //Clear FIFO pointer
    //Write_MFRC522(CommandReg, PCD_IDLE);
 
    //Write data into FIFO 
    for (i=0; i<len; i++)
    { 
        Write_MFRC522(FIFODataReg, *(pIndata+i)); 
    }
    Write_MFRC522(CommandReg, PCD_CALCCRC);
 
    //waite CRC caculation to finish
    i = 0xFF;
    do
    {
        n = Read_MFRC522(DivIrqReg);
        i--;
    }
    while ((i!=0) && !(n&0x04)); //CRCIrq = 1
 
    //read CRC caculation result
    pOutData[0] = Read_MFRC522(CRCResultRegL);
    pOutData[1] = Read_MFRC522(CRCResultRegM);
}
 
 
 
/*
 * Function:MFRC522_Write
 * Description:write block data
 * Input parameters:blockAddr--block address;writeData--Write 16 bytes data into block
 * return:return MI_OK if successed
 */
uchar MFRC522_Write(uchar blockAddr, uchar *writeData)
{
    uchar status;
    uint recvBits;
    uchar i;
    uchar buff[18]; 
     
    buff[0] = PICC_WRITE;
    buff[1] = blockAddr;
    CalulateCRC(buff, 2, &buff[2]);
    status = MFRC522_ToCard(PCD_TRANSCEIVE, buff, 4, buff, &recvBits);
 
    if ((status != MI_OK) || (recvBits != 4) || ((buff[0] & 0x0F) != 0x0A))
    { 
        status = MI_ERR; 
    }
         
    if (status == MI_OK)
    {
        for (i=0; i<16; i++) //Write 16 bytes data into FIFO
        { 
            buff[i] = *(writeData+i); 
        }
        CalulateCRC(buff, 16, &buff[16]);
        status = MFRC522_ToCard(PCD_TRANSCEIVE, buff, 18, buff, &recvBits);
         
        if ((status != MI_OK) || (recvBits != 4) || ((buff[0] & 0x0F) != 0x0A))
        { 
            status = MI_ERR; 
        }
    }
     
    return status;
}
 
 
/*
 * Function:MFRC522_Halt
 * Description:Command the cards into sleep mode
 * Input parameters:null
 * return:null
 */
void MFRC522_Halt(void)
{
    uchar status;
    uint unLen;
    uchar buff[4]; 
 
    buff[0] = PICC_HALT;
    buff[1] = 0;
    CalulateCRC(buff, 2, &buff[2]);
  
    status = MFRC522_ToCard(PCD_TRANSCEIVE, buff, 4, buff,&unLen);
}



Sunday, April 25, 2021

LED BLINKING

                                      LED BLINKING 

led blinking with delay of 1 second

     

HARDWARE REQUIRED:- BUY FROM HERE

1. Audrino board

2. Led

3. 220 ohm resistor

4.Male to Male jumpher wires

5. Breadboard

software required:-

AUDRINO UNO IDE --DOWNLOAD FROM HERE

coding--

void setup()

 {

  // initialize digital pin LED_BUILTIN as an output.

  pinMode(LED_BUILTIN, OUTPUT);

}


// the loop function runs over and over again forever

void loop() 

{

  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);                       // wait for a second

  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);                       // wait for a second

}

     connections--

connect LED small wire to GND of Audrino UNO board and long wire to 220 ohm resistor . connect resistor to pin 13 of Audrino board with the help of jumpher wires.



Saturday, April 24, 2021

ARDUINO LCD PROJECT

                               CONNECTING ARDUINO WITH LCD  SCREEN


HARDWARE REQUIRED:-- Click here to buy

1. LCD screen

2. Arduino Board

3. pin headers to solder to the lcd display pins

4. 10k ohm potentiometer

5. 220 ohm resistor

6. hook up wires

7. breadboard

 software :- Click here to download

CODING :-

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {

 lcd.begin(16, 2);

   lcd.print("hello, world!");

}

void loop()

 {

 lcd.setCursor(0, 1);

   lcd.print(millis() / 1000);

}

CONNECTIONS:-

LCD screen has 16 pins. 1st conncect lcd with breadboard, after that start connecting LCD pins to other hardware components.

1. connect 1st pin of LCD to (-)ve of breadboard.

2.  connect 2nd pin of LCD to (+)ve of breadboard.

3. connect 3rd pin of LCD to center pin of potentiometer.

4. connect 4th pin of LCD to 12th of arduino uno .

5. connect 5th pin of LCD to (-)ve of breadboard.

6. connect 6th pin of LCD to 11th of arduino uno.

7. pin (7,8,9,10) of LCD leaves vacant in this case. 

8. connect (11,12,13,14)th pin of LCD with (5,4,3,2) of arduino board.

9. connect 15th pin of LCD  to 220 ohm resistor and connect resistor to (+)ve of breadboard.

10. connect 16th pin of LCD to (-)ve of breadboard.

11. connect 1st pin of potentiometer to (-)ve and another to (+) of breadboard.

12. connect (-)ve of breadboard to GND of arduino board, and (+)ve to 5v of arduino board.

videos :- click here to watch



Arduino RFID Project

                                       RFID           HARDWARE REQUIRED :- -  Click here to buy 1. Electrobot (UNO R3) Board 2. Usb cable 3....