It is a door opener with mbed and Felica(RFID).
Dependencies: mbed Servo SDFileSystem
main.cpp@2:51b3c5ba45f0, 2011-12-23 (annotated)
- Committer:
- ryought
- Date:
- Fri Dec 23 06:36:59 2011 +0000
- Revision:
- 2:51b3c5ba45f0
- Parent:
- 1:26e3869ba544
- Child:
- 3:046e6f173f9e
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ryought | 1:26e3869ba544 | 1 | #include "mbed.h" |
ryought | 1:26e3869ba544 | 2 | #include "Servo.h" |
ryought | 1:26e3869ba544 | 3 | #include "TextLCD.h" |
ryought | 1:26e3869ba544 | 4 | #include "SDFileSystem.h" |
ryought | 1:26e3869ba544 | 5 | |
ryought | 1:26e3869ba544 | 6 | TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 |
ryought | 1:26e3869ba544 | 7 | Serial pc(USBTX, USBRX); |
ryought | 1:26e3869ba544 | 8 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
ryought | 1:26e3869ba544 | 9 | |
ryought | 1:26e3869ba544 | 10 | void logWrite(){ |
ryought | 1:26e3869ba544 | 11 | } |
ryought | 1:26e3869ba544 | 12 | |
ryought | 1:26e3869ba544 | 13 | int main() { |
ryought | 1:26e3869ba544 | 14 | lcd.printf("Hello World\n RFID_doorlock"); |
ryought | 1:26e3869ba544 | 15 | printf("hello world"); |
ryought | 2:51b3c5ba45f0 | 16 | wait(1); |
ryought | 2:51b3c5ba45f0 | 17 | lcd.cls(); |
ryought | 2:51b3c5ba45f0 | 18 | lcd.printf("opening files now..."); |
ryought | 1:26e3869ba544 | 19 | FILE *fp = fopen("/sd/rdoor/userlist.txt", "r"); //user list(sd) |
ryought | 1:26e3869ba544 | 20 | FILE *fp2 = fopen("/sd/rdoor/log.txt", "a"); //logfile(sd) |
ryought | 1:26e3869ba544 | 21 | fprintf(fp2, "Power source is turned on now") ;//power on log |
ryought | 2:51b3c5ba45f0 | 22 | wait(1); |
ryought | 1:26e3869ba544 | 23 | |
ryought | 1:26e3869ba544 | 24 | if (fp == NULL) { |
ryought | 1:26e3869ba544 | 25 | lcd.cls(); //gamen no syokika |
ryought | 1:26e3869ba544 | 26 | lcd.printf("could not read USERLIST"); |
ryought | 1:26e3869ba544 | 27 | fprintf(fp2, "could not read USERLIST.TXT\n"); //readerror log |
ryought | 2:51b3c5ba45f0 | 28 | error("could not read USERLIST.TXT\n"); |
ryought | 2:51b3c5ba45f0 | 29 | } else { |
ryought | 2:51b3c5ba45f0 | 30 | lcd.printf("Completed opening files!!"); |
ryought | 1:26e3869ba544 | 31 | } |
ryought | 1:26e3869ba544 | 32 | fclose(fp); |
ryought | 1:26e3869ba544 | 33 | fclose(fp2); |
ryought | 1:26e3869ba544 | 34 | |
ryought | 1:26e3869ba544 | 35 | lcd.cls(); |
ryought | 1:26e3869ba544 | 36 | lcd.printf("Thank you! i will sleep soon"); |
ryought | 1:26e3869ba544 | 37 | } |