Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 11:6e862985089f
- Parent:
- 10:0a444736aeb8
- Child:
- 12:d8370e1350db
--- a/main.cpp Fri May 03 12:52:41 2019 +0000 +++ b/main.cpp Fri May 03 13:53:27 2019 +0000 @@ -42,7 +42,7 @@ RFID IRQ = pin5 -> -------- OPEN -------- ======================= RFID 2 ====================================== RFID SDA = pin1 -> SPI_CS PA_12=D2 PTD5 - RFID RST = pin7 -> PB_1=D6 PTC9 <- might not be good + RFID RST = pin7 -> PB_1=D6 PTC9 RFID IRQ = pin5 -> -------- OPEN -------- ===================================================================== @@ -122,6 +122,15 @@ DigitalOut LedGreen(LED1); //Blinks when a card is read +//Define the latches +DigitalOut r0_set(FRONTDOOR_SET); +DigitalOut r0_rst(FRONTDOOR_RST); +DigitalOut r1_set(ROOM1DOOR_SET); +DigitalOut r1_rst(ROOM1DOOR_RST); + +bool r0_state; +bool r1_state; + //Serial connection to terminal for output Serial pc(SERIAL_TX, SERIAL_RX); @@ -136,6 +145,20 @@ rfid1.PCD_Init(); rfid2.PCD_Init(); + printf("Resetting latches...\n\r"); + r0_set = 0; + r0_rst = 1; + r0_state = false; + r1_set = 0; + r1_rst = 1; + r1_state = false; + wait_ms(500); + r0_rst = 0; + r1_rst = 0; + printf("Done.\n\r"); + + printf("Starting RFID monitoring...\n\r"); + while (true) { LedGreen = 1; @@ -149,7 +172,16 @@ printf(" %02X", rfid1.uid.uidByte[i]); } printf("\n\r"); - wait_ms(200); + + //pulse room 0 (front door) latch + r0_state = !r0_state; + r0_set = r0_state; + r0_rst = !r0_state; + wait_ms(100); + r0_set = 0; + r0_rst = 0; + + wait_ms(500); } } //end rfid1 @@ -164,6 +196,15 @@ printf(" %02X", rfid2.uid.uidByte[i]); } printf("\n\r"); + + //pulse room 1 (front door) latch + r1_state = !r1_state; + r1_set = r1_state; + r1_rst = !r1_state; + wait_ms(100); + r1_set = 0; + r1_rst = 0; + wait_ms(200); } } //end rfid2