hmc5883l
Dependencies: HMC5883L LCD4884 MFRC522 eeprom mbed
Diff: project.cpp
- Revision:
- 4:b56a8a051fdd
- Parent:
- 3:987e54d48f77
- Child:
- 5:4af4865f462b
--- a/project.cpp Mon Dec 07 17:51:59 2015 +0000 +++ b/project.cpp Tue Dec 08 16:11:25 2015 +0000 @@ -18,7 +18,7 @@ DigitalIn Switch1(PC_5); DigitalIn Switch2(PC_6); InterruptIn Sw2(PC_6); -InterruptIn Sw3(PC_4); + uint8_t mode=0; uint8_t selectitem=0,place=0; @@ -51,7 +51,7 @@ pc.baud(9600); Sw1.rise(&ItrSw1); Sw2.rise(&ItrSw2); - Sw3.rise(&ItrSw3); + string NameJune="Natthanicha",recieveNameJune,SurJune="Jamroonpan",recieveSurJune,IdJune="57340500023",recieveIdJune; //June start @ 1-36 string NameO="Sirawat",recieveNameO,SurO="Sok",recieveSurO,IdO="57340500071",recieveIdO; uint8_t UID[8],recieveUID[8]; @@ -98,10 +98,11 @@ wait(2); lcd.LCD_clear(); while(1) { - //lcd.LCD_write_string(0,0,"SCAN ID CARD",0); + lcd.LCD_write_string(0,0,"SCAN ID CARD",0); if ( ! RFID.PICC_IsNewCardPresent()) // Look for new cards continue; if ( ! RFID.PICC_ReadCardSerial()) // Select one of the cards + continue; pc.printf("Card UID: "); for (uint8_t i = 0; i < RFID.uid.size; i++) @@ -110,6 +111,7 @@ if( RFID.uid.uidByte[0]==recieveUID[0] && RFID.uid.uidByte[1]==recieveUID[1] && RFID.uid.uidByte[2]==recieveUID[2] && RFID.uid.uidByte[3]==recieveUID[3] ) { //จำ pc.printf("%s\t%s\t%s\n",recieveNameJune,recieveSurJune,recieveIdJune); + lcd.LCD_clear(); string name,sur; eeprom.read(1,&name,11); eeprom.read(12,&sur,10); @@ -122,6 +124,7 @@ //จำ string name,sur; + lcd.LCD_clear(); eeprom.read(41,&name,7); eeprom.read(48,&sur,3); printstring(0,0,name,7,0); @@ -131,7 +134,7 @@ //lcd.LCD_clear(); lcd.LCD_write_string(0,2,"1 select item",0); lcd.LCD_write_string(0,3,"2 select place",0); - lcd.LCD_write_string(40,5,"cancel",0); + //lcd.LCD_write_string(40,5,"cancel",0); while(1) { if(mode==1) { printf("1"); @@ -148,7 +151,8 @@ sprintf(str,"item : %d",selectitem); printstring(3,2,str,8,0); } - if(Switch2.read()==1) { + if(Switch2.read()==1 && selectitem !=0) { + mode=1; char str[10]; place=((int) (Rnd.read()*1000))%4 +1; wait(0.2); @@ -168,6 +172,7 @@ lcd.LCD_write_string(0,1,"select place",0); while(1) { if(Switch1.read()==1) { + mode=2; char str[10]; place++; if(place > 4) @@ -176,7 +181,7 @@ sprintf(str,"place : %d",place); printstring(3,2,str,9,0); } - if(Switch2.read()==1) { + if(Switch2.read()==1 && place!=0) { char str[10]; selectitem=((int) (Rnd.read()*1000))%9 +1; wait(0.2); @@ -184,15 +189,17 @@ printstring(3,3,str,8,0); break; } + } + while(1) {} + } + if(mode==3) { + printf("0"); - } - if(mode==0) { - printf("0"); - } - printf("mode=%d",mode); + } + printf("mode=%d",mode); - } //end while loop - } + } //end while mode loop + } - } } +