Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
Membrane 3x4 Matrix Keypad + extras - 3x4
Buzzer
Project description
Code
Code
arduino
1//2020 Ali_Kilicoglu 2 3 4 5#include <Servo.h> 6Servo servoNesnesi; 7 8#include <Keypad.h> 9String pasword1="Your password"; 10String pasword2=""; 11int p=0; 12 13 14const byte ROWS = 4; //four rows 15const byte COLS = 3; //three columns 16 17char keys[ROWS][COLS] = { 18 {'1','2','3'}, 19 {'4','5','6'}, 20 {'7','8','9'}, 21 {'*','0','#'} 22}; 23byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad 24byte colPins[COLS] = {5, 4, 3}; //connect to the column pinouts of the keypad 25 26//Create an object of keypad 27Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); 28 29void setup(){ 30 Serial.begin(9600); 31 #define BUZZERPIN 11 32 33 servoNesnesi.attach(10); 34 pinMode(BUZZERPIN,OUTPUT); 35 36 servoNesnesi.write(100);//first lock drawer 37 38 Serial.begin(9600); 39 40} 41 42 43 44 45 46 47void loop(){ 48 char key = keypad.getKey();// Read the key 49 50 // Print if key pressed 51 if (key){ 52 53 Serial.print("Key print : "); 54 Serial.println(key); 55 56 digitalWrite(BUZZERPIN,HIGH); 57 delay(100); 58 digitalWrite(BUZZERPIN,LOW); 59 p = pasword2.length(); 60 pasword2+= key; 61 Serial.println(pasword2); 62 } 63 if(pasword2 == pasword1){//if your pasword equal keypad pasword 64 servoNesnesi.write(20);//open the drawer 65 pasword2=""; 66 67 } 68 else if(pasword2 !=pasword1 and p>= 6){ 69 70 digitalWrite(BUZZERPIN,HIGH); 71 pasword2=""; 72 73 } 74 if(key == '#'){//for lock the drawer 75 servoNesnesi.write(100); 76 pasword2=""; 77 78 79 } 80 81 } 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
Downloadable files
Shematic
Shematic
Shematic
Shematic
Comments
Only logged in users can leave comments