RFID with HC06 bluetooth and ESP wifi module
Dependencies: mbed MFRC522 ESP8266
Diff: main.cpp
- Revision:
- 1:ad028c0c6c6c
- Parent:
- 0:ebf3612d4985
- Child:
- 2:9a39ebd76683
--- 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); } }