Marvas / Mbed 2 deprecated rfid_kart_okuma

Dependencies:   mbed MFRC522 TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //rfid ve lcd ekran kullanimi
00002 
00003 #include "mbed.h"
00004 #include "TextLCD.h"
00005 #include <iostream>
00006  #include "MFRC522.h"
00007 Serial seriport(USBTX,USBRX);
00008 TextLCD lcd(PB_0,PA_4,PC_3,PC_2,PB_3,PA_10);
00009 
00010 
00011  //KL25Z Pins for MFRC522 SPI interface
00012  #define SPI_MOSI    PA_7 //Master output slave input
00013  #define SPI_MISO    PA_6  //Master input slave Output
00014  #define SPI_SCLK    PA_5 //SCK Clock pulse saat darbesi
00015  #define SPI_CS      PB_6 //SDA data pini
00016  // KL25Z Pin for MFRC522 reset
00017  #define MF_RESET    PC_7 //RST
00018 
00019  MFRC522  RfChip(SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET);
00020 
00021  int main(void) {
00022 
00023    // Init. RC522 Chip
00024    RfChip.PCD_Init();
00025 
00026    while (true) {
00027 
00028 
00029      // Look for new cards
00030      if ( ! RfChip.PICC_IsNewCardPresent())
00031      {
00032        wait_ms(100);
00033        continue;
00034      }
00035 
00036 
00037 
00038      // Select one of the cards
00039      if ( ! RfChip.PICC_ReadCardSerial())
00040      {
00041        wait_ms(100);
00042        continue;
00043      }
00044 
00045      // Print Card UID
00046      printf("Kart ID: ");
00047      for (uint8_t i = 0; i < RfChip.uid.size; i++)
00048      {
00049        printf(" %X", RfChip.uid.uidByte[i]);
00050      }
00051      printf("\n");
00052 
00053      // Print Card type
00054      uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
00055      printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
00056    }
00057  }