smart fridge using RFID and Bluetooth
Revision 1:ad028c0c6c6c, committed 2019-04-15
- Comitter:
- rajas1812
- Date:
- Mon Apr 15 20:34:43 2019 +0000
- Parent:
- 0:ebf3612d4985
- Commit message:
- Smart fridge using RFID
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Mar 25 22:37:10 2016 +0000
+++ b/main.cpp Mon Apr 15 20:34:43 2019 +0000
@@ -16,6 +16,9 @@
//MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET);
MFRC522 RfChip (PTD2, PTD3, PTD1, PTE25, PTD0);
+int counter1 = 0;
+int counter2 = 0;
+
int main(void) {
blue.baud(9600);
@@ -54,23 +57,41 @@
blue.printf(" %X02 ", RfChip.uid.uidByte[i]);
a = RfChip.uid.uidByte[0];
}
+ printf("%d",a);
//Print Card Type
- if(a==117 || a==177)
+ if(a==73)
{
- printf("\r\nWhite Card");
+ if(counter1 == 0){
+ printf("\r\nMilk is in the fridge");
blue.printf("\r\nWhite Card");
+ counter1 = 1;
}
- else if(a==226 || a==20)
+ else if(counter1 == 1){
+ printf("\r\nMilk is out of the fridge");
+ counter1 = 0;
+ }
+ }
+
+ if(a==207)
{
- printf("\r\nBlue Keychain");
- blue.printf("\r\nBlue Keychain");
- }
- else
- {
- printf("\r\nUnrecognized");
- blue.printf("\r\nUnrecognized");
- }
+ if (counter2 == 0)
+ {
+ printf("\r\nBeer is in the fridge");
+ blue.printf("\r\nBlue Keychain");
+ counter2 = 1;
+ }
+ else if (counter2 == 1){
+ printf("\r\nBeer is out of the fridge");
+ counter2 = 0;
+ }
+ }
+ //wait(1);
+ // else
+ // {
+ // printf("\r\nUnrecognized");
+ // blue.printf("\r\nUnrecognized");
+ //}
printf("\n\r");
blue.printf("\n\r");
@@ -79,7 +100,7 @@
printf("PICC Type: %s \n\n\r\r", RfChip.PICC_GetTypeName(piccType));
blue.printf("PICC Type: %s \n\n\r\r", RfChip.PICC_GetTypeName(piccType));
- wait_ms(200);
+ wait(2);
}
}