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

Dependencies:   mbed Servo SDFileSystem

main.cpp

Committer:
ryought
Date:
2011-12-25
Revision:
3:046e6f173f9e
Parent:
2:51b3c5ba45f0
Child:
4:f71760338b1e

File content as of revision 3:046e6f173f9e:

#include "mbed.h"
#include "Servo.h"
#include "TextLCD.h"
#include "SDFileSystem.h"

TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
Serial pc(USBTX, USBRX);
SDFileSystem sd(p5, p6, p7, p8, "sd");

FILE *fp = fopen("/sd/rdoor/userlist.txt", "r"); //user list(in sd)
FILE *fp2 = fopen("/sd/rdoor/log.txt", "a"); //logfile(in sd)

void logSetup(){
    if (fp2 == NULL) {
        lcd.cls();
        lcd.printf("could not read LOGFILES! please check it");
        error("could not read LOGFILES\n");
    } else {
        fprintf(fp2, "[start] Power souce is turned on now.\n");
    }
    
    if (fp == NULL) {
        lcd.cls();
        lcd.printf("could not read USERLIST!");
        fprintf(fp2, "[error] could not read USERLIST.TXT!!\n"); //errorlog out
        error("could not read USERLIST\n");
    } else {
        lcd.cls();
        lcd.printf("files was completely opened");
        fprintf(fp2, "[ok] USERLIST.TXT was loaded.\n");
    }
    
    fprintf(fp2, "[ok] system is ready\n");
    
}


int main() {
    lcd.printf("Hello World\n RFID_doorlock");
    printf("hello world"); //for debug
    
    logSetup();

    
    //closing files
    fprintf(fp2, "[end] thank you.\n \n");
    fclose(fp);
    fclose(fp2);
    lcd.cls();
    lcd.printf("Thank you! i will sleep soon");    
}