Upload Kazakhstanmozrt.ino
Browse files- Kazakhstanmozrt.ino +100 -0
Kazakhstanmozrt.ino
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <LiquidCrtstal.h>
|
| 2 |
+
#include <Servo.h>
|
| 3 |
+
#include <Keypad.h>
|
| 4 |
+
Servo myservo;
|
| 5 |
+
int pos=0; // servo motor position
|
| 6 |
+
LiquidCrystal lcd(A4, A5, A3, A2, A1 A0);
|
| 7 |
+
const byte rows=4;
|
| 8 |
+
const byte cols=3;
|
| 9 |
+
|
| 10 |
+
char key[rows][cols]={
|
| 11 |
+
{"1", "2", "3"},
|
| 12 |
+
{"4", "5", "6"},
|
| 13 |
+
{"7", "8", "9"},
|
| 14 |
+
{"*", "0", "#"}
|
| 15 |
+
};
|
| 16 |
+
byte rowPins[rows]=[0,1,2,3];
|
| 17 |
+
byte colPins[cols]=[4,5,6];
|
| 18 |
+
Keypad keypad = Keypad(makeKeymap(key), rowPins, colPins, rows, cols);
|
| 19 |
+
char* password="0123";
|
| 20 |
+
int currentpositiion=0;
|
| 21 |
+
|
| 22 |
+
void setup() {
|
| 23 |
+
// put your setup code here, to run once:
|
| 24 |
+
Serial.begin(9600);
|
| 25 |
+
myservo.attach(9); //motor connection of servo
|
| 26 |
+
|
| 27 |
+
lcd.begin(16,2);
|
| 28 |
+
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
void loop()
|
| 32 |
+
{
|
| 33 |
+
if (currentposition==0)
|
| 34 |
+
{
|
| 35 |
+
displayscreen();
|
| 36 |
+
}
|
| 37 |
+
int 1 ;
|
| 38 |
+
char code=keypad.getKey();
|
| 39 |
+
if(code!=NO_KEY)
|
| 40 |
+
{
|
| 41 |
+
lcd.clear();
|
| 42 |
+
lcd.setCursor(0,0);
|
| 43 |
+
lcd.print("PASSWORD:");
|
| 44 |
+
lcd.setCursor(7,1);
|
| 45 |
+
lcd.print(" ");
|
| 46 |
+
lcd.setCursor(7,1);
|
| 47 |
+
for(1=0;1<=currentposition;++1)
|
| 48 |
+
{
|
| 49 |
+
lcd.print("*");
|
| 50 |
+
//keypress();
|
| 51 |
+
}
|
| 52 |
+
if (code==password(currentposition))
|
| 53 |
+
{
|
| 54 |
+
++currentpositiion;
|
| 55 |
+
if(currentposition==4)
|
| 56 |
+
{
|
| 57 |
+
unlockdoor();
|
| 58 |
+
currentposition=0;
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
void unlockdoor()
|
| 64 |
+
{
|
| 65 |
+
delay(900);
|
| 66 |
+
|
| 67 |
+
lcd.setCursor(0,0);
|
| 68 |
+
lcd.println(" ");
|
| 69 |
+
lcd.setCursor(1,0);
|
| 70 |
+
lcd.print("Access Granted");
|
| 71 |
+
lcd.setCursor(4,1);
|
| 72 |
+
lcd.println("WELCOME!!");
|
| 73 |
+
lcd.setCursor(15,1);
|
| 74 |
+
lcd.println(" ");
|
| 75 |
+
lcd.setCursor(16,1);
|
| 76 |
+
lcd.println(" ");
|
| 77 |
+
lcd.setCursor(14,1);
|
| 78 |
+
lcd.println(" ");
|
| 79 |
+
lcd.setCursor(13,1);
|
| 80 |
+
lcd.print(" ");
|
| 81 |
+
|
| 82 |
+
for(pos = 180; pos>=0; pos-=5) // open the door
|
| 83 |
+
{
|
| 84 |
+
myservo.write(pos);
|
| 85 |
+
delay(5);
|
| 86 |
+
}
|
| 87 |
+
delay(2000);
|
| 88 |
+
|
| 89 |
+
delay(1000);
|
| 90 |
+
counterbeed();
|
| 91 |
+
|
| 92 |
+
delay(1000);
|
| 93 |
+
|
| 94 |
+
for(pos = 0; pos <= 170; pos +=5) // close the door
|
| 95 |
+
{
|
| 96 |
+
// in steps of 1 degree
|
| 97 |
+
myservo.write(pos);
|
| 98 |
+
delay(15);
|
| 99 |
+
}
|
| 100 |
+
}
|