A simple digital lock with attempted audio guidance

Dependencies:   FATFileSystem TextLCD mbed

Fork of Digital_Lock_with_audio by NITH ece

Revision:
2:9bdba6204bb4
Parent:
1:85eb1c94154a
Child:
4:74d697416c75
--- a/main.cpp	Tue Apr 23 12:49:09 2013 +0000
+++ b/main.cpp	Sat May 11 12:00:13 2013 +0000
@@ -1,4 +1,27 @@
+/* Digital Lock System
+Components Used:
+NGX Baseboord
+MPR121 Capacitive touch panel as keypad( p26, p9, p10)// IRQ, SDA, SCL
+LCD for display(p24, p25, p27, p28, p29, p30) // rs, e, d4-d7
+Motor for opening/closing the lock(p11, p12) // for input in H Bridge 
+Baseboard SD Card for storing Forest.wav
+Baseboard audio jack 3.5 mm 
 
+By using touch panel as input we enter the desired password to open the lock. 
+Initially we store a password in array ORG[] which can be compared with the password(length= 7)entered by the user.
+
+If the entered password is correct then motor opens the door. 
+In case of wrong password the user is asked to re-enter the password. 3 trials are given after which door is permanently
+ locked.
+Option to change the password is also provided.
+The process is guided by display of instruction on the LCD. 
+
+
+Under Progress:
+An attempt is being made to guide the user by playing relavent audio files along with the instructions on LCD. 
+The "forest.wav" file is the one that we are attempting to play along with LCD instructions.
+the bit rate of the wave file is 176kbps.  
+*/
 
 
 
@@ -29,7 +52,9 @@
 int Nums[7] = {0,0,0,0,0,0,0};
 int counter = 0;
 int count2 = 0;
- 
+int k=0;
+DigitalOut myled(p11);
+DigitalOut myled1(p12);
 //------------------------------------------- Create the interrupt receiver object on pin 26
 InterruptIn interrupt(p26);
  
@@ -197,6 +222,7 @@
 
 //-------------------------------------------------------------------------------obtaining input
 
+
 void fallInterrupt() {
 int key_code=0;
     int i=0;
@@ -208,11 +234,17 @@
     for (i=0; i<12; i++) 
     {
         if (((value>>i)&0x01)==1) 
-        {
+        {  
+           if(counter==0)
+             {
+              lcd.cls();
+              lcd.printf("");
+             }
             key_code=i;
             lcd.printf("%d", i);
             if(counter < 7)
             {
+               
                 Nums[counter] = i;
                 counter++;
             }
@@ -258,7 +290,7 @@
 AGAIN:    
     lcd.cls();
     lcd.printf("1-open door\n2-reset password");
-    play_wave("/sd/forest.wav");
+    //play_wave("/sd/forest.wav");
     interrupt.fall(&fallInterrupt);
     interrupt.mode(PullUp);
   
@@ -270,7 +302,7 @@
     lcd.cls();    
     //---------------------------------------------------enter the password
     lcd.printf("enter your password\n");
-    play_wave("/sd/forest.wav");
+    //play_wave("/sd/forest.wav");
     wait(1);
     
     while(1)
@@ -297,14 +329,21 @@
                               lcd.cls();
                               lcd.printf("opening door...\n"); 
                            // play_wave("/sd/forest.wav");
-                              wait(10);
+                              myled = 1;
+        myled1 = 0;
+        wait(5);
+        myled = 0;
+        myled1 = 1;
+        wait(5);
                               goto AGAIN;
                            }
        else
        {
+       
        lcd.cls();
        lcd.printf("password incorrect.retry\n"); 
-        play_wave("/sd/forest.wav");
+       play_wave("/sd/forest.wav");
+       wait(10);
        goto AGAIN;
        }
        }
@@ -356,10 +395,21 @@
        {
         lcd.cls();
         lcd.printf("password incorrect.retry\n");
+       k++;
+       if(k==3)
+       {
+       lcd.cls();
+        lcd.printf("Locked");
+        wait(30);
+       }
        play_wave("/sd/forest.wav");
         goto AGAIN;
         }
         }
 }
+else
+{
+goto AGAIN;
 }
 }
+}