It is a door opener with mbed and Felica(RFID).

Dependencies:   mbed Servo SDFileSystem

Committer:
ryought
Date:
Sun Dec 25 02:30:11 2011 +0000
Revision:
3:046e6f173f9e
Parent:
2:51b3c5ba45f0
Child:
4:f71760338b1e

        

Who changed what in which revision?

UserRevisionLine numberNew 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 3:046e6f173f9e 10 FILE *fp = fopen("/sd/rdoor/userlist.txt", "r"); //user list(in sd)
ryought 3:046e6f173f9e 11 FILE *fp2 = fopen("/sd/rdoor/log.txt", "a"); //logfile(in sd)
ryought 3:046e6f173f9e 12
ryought 3:046e6f173f9e 13 void logSetup(){
ryought 3:046e6f173f9e 14 if (fp2 == NULL) {
ryought 3:046e6f173f9e 15 lcd.cls();
ryought 3:046e6f173f9e 16 lcd.printf("could not read LOGFILES! please check it");
ryought 3:046e6f173f9e 17 error("could not read LOGFILES\n");
ryought 3:046e6f173f9e 18 } else {
ryought 3:046e6f173f9e 19 fprintf(fp2, "[start] Power souce is turned on now.\n");
ryought 3:046e6f173f9e 20 }
ryought 3:046e6f173f9e 21
ryought 3:046e6f173f9e 22 if (fp == NULL) {
ryought 3:046e6f173f9e 23 lcd.cls();
ryought 3:046e6f173f9e 24 lcd.printf("could not read USERLIST!");
ryought 3:046e6f173f9e 25 fprintf(fp2, "[error] could not read USERLIST.TXT!!\n"); //errorlog out
ryought 3:046e6f173f9e 26 error("could not read USERLIST\n");
ryought 3:046e6f173f9e 27 } else {
ryought 3:046e6f173f9e 28 lcd.cls();
ryought 3:046e6f173f9e 29 lcd.printf("files was completely opened");
ryought 3:046e6f173f9e 30 fprintf(fp2, "[ok] USERLIST.TXT was loaded.\n");
ryought 3:046e6f173f9e 31 }
ryought 3:046e6f173f9e 32
ryought 3:046e6f173f9e 33 fprintf(fp2, "[ok] system is ready\n");
ryought 3:046e6f173f9e 34
ryought 1:26e3869ba544 35 }
ryought 1:26e3869ba544 36
ryought 3:046e6f173f9e 37
ryought 1:26e3869ba544 38 int main() {
ryought 1:26e3869ba544 39 lcd.printf("Hello World\n RFID_doorlock");
ryought 3:046e6f173f9e 40 printf("hello world"); //for debug
ryought 1:26e3869ba544 41
ryought 3:046e6f173f9e 42 logSetup();
ryought 3:046e6f173f9e 43
ryought 3:046e6f173f9e 44
ryought 3:046e6f173f9e 45 //closing files
ryought 3:046e6f173f9e 46 fprintf(fp2, "[end] thank you.\n \n");
ryought 1:26e3869ba544 47 fclose(fp);
ryought 1:26e3869ba544 48 fclose(fp2);
ryought 1:26e3869ba544 49 lcd.cls();
ryought 1:26e3869ba544 50 lcd.printf("Thank you! i will sleep soon");
ryought 1:26e3869ba544 51 }