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

Dependencies:   mbed Servo SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
ryought
Date:
Sun Dec 25 11:33:15 2011 +0000
Parent:
4:f71760338b1e
Child:
6:9fe8caff6142
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Dec 25 10:29:35 2011 +0000
+++ b/main.cpp	Sun Dec 25 11:33:15 2011 +0000
@@ -7,10 +7,15 @@
 Serial pc(USBTX, USBRX);
 SDFileSystem sd(p5, p6, p7, p8, "sd");
 Servo myServo(p21); //port-21 = doorlock servo
+//DigitalIn button1(p22);
+InterruptIn int_p22(p22);
+DigitalOut int_led(LED4);
 
 FILE *fp = fopen("/sd/rdoor/userlist.txt", "r"); //user list(in sd)
 FILE *fp2 = fopen("/sd/rdoor/log.txt", "a"); //logfile(in sd)
 
+bool exit_button = false;
+
 //char servoStatus;
 
 class Watchdog {
@@ -32,6 +37,15 @@
 
 Watchdog w;
 
+void int_rise() {
+    int_led = !int_led;
+    exit_button = !exit_button;
+    /*
+    lcd.locate(15, 1);
+    lcd.printf("E"); */
+}
+
+
 void logSetup(){
     if (fp2 == NULL) {
         lcd.cls();
@@ -100,25 +114,38 @@
 
 
 int main() {
-    w.kick(2.5);
+    //w.kick(10);
     lcd.printf("Hello World\n RFID_doorlock");
     printf("hello world"); //for debug
     wait(1);
     
+    
     logSetup();
     
     //kokono aida ni felica
-    openDoor();
-    wait(3);
+    int_p22.rise(&int_rise);
     
-    closeDoor();
-    wait(3);
+    while(1) {
+        openDoor();
+        wait(3);
+        
+        closeDoor();
+        wait(3);
+        if (exit_button == true) {
+            break;
+        }
+    }
 
     //closing files
+    int_led = 0;
+
+    fclose(fp);
+    fprintf(fp2, "[ok] USERLIST.TXT closed.");
     fprintf(fp2, "[end] thank you.\n \n");
-    fclose(fp);
     fclose(fp2);
-    w.kick();
+    
     lcd.cls();
-    lcd.printf("Thank you!  bye!");    
+    lcd.printf("Thank you!  bye!");   
+    wait(3);
+    //w.kick(); 
 }
\ No newline at end of file