hmc5883l

Dependencies:   HMC5883L LCD4884 MFRC522 eeprom mbed

Revision:
0:930d2bc16788
Child:
1:7556e9c47b98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project.cpp	Sun Dec 06 13:10:54 2015 +0000
@@ -0,0 +1,93 @@
+#include "mbed.h"
+#include "LCD4884.h"
+#include "MFRC522.h"
+#include "eeprom.h"
+#include "string.h"
+
+
+// KL25Z Pin for MFRC522 reset
+#define MF_RESET    D9
+
+
+EEPROM  eeprom(I2C_SDA,I2C_SCL,0);
+Serial  pc(SERIAL_TX,SERIAL_RX);
+LCD4884 lcd;
+MFRC522 RFID(D11, D12, D13, D10, MF_RESET);
+
+
+int main()
+{
+    pc.baud(9600);
+    int8_t recieve[12]={0};
+    int8_t cmd[12];
+    cmd[0] = 186;
+    cmd[1] = 23;
+    cmd[2] = 37;
+    cmd[3] = 231;
+    cmd[4] = 57;
+    cmd[5] = 3;
+    cmd[6] = 106;
+    cmd[7] = 224;
+    cmd[8] = 37;
+    cmd[9] = 231;
+    cmd[10] = 57;
+    cmd[11] = 23;
+    char name[
+    //char name[
+    eeprom.write(100,cmd,24);
+    wait_ms(10);
+    eeprom.read(100,recieve,24);
+    wait_ms(100);
+    /*for(i=0;i<=11;i++)
+    {
+        pc.printf("%d\n",cmd[i]);
+        pc.printf("recieve = %d\n",recieve[i]);
+        }*/
+    RFID.PCD_Init();
+    lcd.LCD_init();
+    lcd.backlight(ON);
+    lcd.LCD_write_string(0,0,"SCAN ID CARD",0);
+    wait(1);
+    lcd.LCD_clear();
+    while(1)
+    {   
+       // if(
+ 
+        if ( ! RFID.PICC_IsNewCardPresent()) // Look for new cards
+        {
+            wait_ms(500);
+            continue;
+        }
+        if ( ! RFID.PICC_ReadCardSerial())   // Select one of the cards
+        {
+            wait_ms(500);
+            continue;
+        }
+        //for(i=0;i<=11;i++){
+       // pc.printf("%d\n",cmd[i]);
+      // pc.printf("%d\n",recieve[i]);}
+        pc.printf("Card UID: ");
+        for (uint8_t i = 0; i < RFID.uid.size; i++)
+        {
+            pc.printf(" %d", RFID.uid.uidByte[i]);
+        }
+        printf("\n\r");
+
+        if( RFID.uid.uidByte[0]==recieve[0] && RFID.uid.uidByte[1]==recieve[1] && RFID.uid.uidByte[2]==recieve[2] && RFID.uid.uidByte[3]==recieve[3] )
+        {
+            pc.printf("Kritayos Thongtem\t\t%d3405000%d\n",recieve[4],recieve[5]);
+            lcd.LCD_write_string(0,0,"Tuek",0);
+        }
+        if( RFID.uid.uidByte[0]==recieve[6] && RFID.uid.uidByte[1]==recieve[7] && RFID.uid.uidByte[2]==recieve[8] && RFID.uid.uidByte[3]==recieve[9] )
+        {
+            pc.printf("Natthanicha Jamroonpan\t\t%d3405000%d\n",recieve[10],recieve[11]);
+            char C[2];
+            C[0]=recieve[5];
+              C[1]=recieve[6];
+            lcd.LCD_write_string(0,0,C,0);
+        }
+    
+    }    
+    
+}
+