servo lcd keypad

Dependencies:   Keypadlatest Servo TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
mijimy
Date:
Thu Aug 10 04:18:13 2017 +0000
Commit message:
simple lock

Changed in this revision

Keypadlatest.lib Show annotated file Show diff for this revision Revisions of this file
Servo.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0a49e3262526 Keypadlatest.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keypadlatest.lib	Thu Aug 10 04:18:13 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/tatiuc-embedded/code/Keypadlatest/#909929293a23
diff -r 000000000000 -r 0a49e3262526 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Thu Aug 10 04:18:13 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 0a49e3262526 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu Aug 10 04:18:13 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 0a49e3262526 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Aug 10 04:18:13 2017 +0000
@@ -0,0 +1,65 @@
+ #include "mbed.h"
+ #include "Keypad.h"
+ #include "TextLCD.h"  // insert lcd library
+ #include "Servo.h"
+ 
+ 
+Servo myservo(PB_0);
+TextLCD display(D8, D9, D4, D5, D6, D7); // rs, e, d4-d7 // declare lcd
+const char password[]={"123456"};
+char getkey();
+bool compare();
+ char kpdLayout[4][4] = {{'1' ,'2' ,'3' ,'A'},  //row0
+                        {'4' ,'5' ,'6' ,'B'},  //row1
+                        {'7' ,'8' ,'9' ,'C'},  //row2
+                        {'*' ,'0' ,'#' ,'D'}}; //row3
+ 
+ Keypad kpad(PB_13, PB_14, PB_15, PB_1, PB_11, PB_12, PA_11, PA_12);
+ char key[6];
+  int main() {
+      int i;      
+      display.printf("locker system");
+      //myservo = 0.0;
+      wait(2);
+      display.cls();
+      while(1){
+          myservo = 0.0;
+          display.locate(0,0); // col 1 row 1
+          display.printf("password:");          
+          for(i=0;i<6;i++)  // get 6 password
+          { key[i]=getkey();
+            display.printf("*");
+            }
+          if(compare()==1)
+          { display.locate(2,1); // col 1 row 1 
+            display.printf("accepted");
+            myservo = 1.0;
+          }
+          else
+          { display.locate(2,1); // col 1 row 1 
+            display.printf("wrong   ");
+          }            
+          wait(3);
+          display.cls(); 
+      }
+  }
+
+char getkey()  //get keypad input
+{    char keyin;
+     while(kpad.ReadKey()=='\0'); //wait until presses
+     keyin = kpad.ReadKey();                   //read the current key pressed
+     while(kpad.ReadKey()!='\0'); //wait until depresses
+     return keyin;
+    }
+    
+bool compare()  //compare password
+{   bool result=1;
+    int i;
+    for(i=0;i<6;i++)
+    {   if(password[i]!=key[i])
+        {   result=0;
+            break;
+        }
+    }  
+    return result;    
+}
\ No newline at end of file
diff -r 000000000000 -r 0a49e3262526 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Aug 10 04:18:13 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/fd96258d940d
\ No newline at end of file