Advertisement
Guest User

Help.....

a guest
Mar 31st, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. #include <Password.h>
  2.  
  3. #include <Wire.h>
  4. #include <LCD.h>
  5. #include <LiquidCrystal.h>
  6. #include <LiquidCrystal_I2C.h>
  7. #include <LiquidCrystal_SI2C.h>
  8.  
  9.  
  10. #include <Keypad.h>
  11. #include <Servo.h>
  12.  
  13. int greenLight = 11;
  14. int redLight = 12;
  15. int servoPin = 3;
  16. int amount1 = 0;
  17.  
  18. #define int servoPin = 13;
  19. #define I2C_ADDR 0x27
  20. #define BACKLIGHT_PIN 3
  21. #define En_pin 2
  22. #define Rw_pin 1
  23. #define Rs_pin 0
  24. #define D4_pin 4
  25. #define D5_pin 5
  26. #define D6_pin 6
  27. #define D7_pin 7
  28.  
  29. const byte rows = 4; //four rows
  30. const byte cols = 4; //three columns
  31. char keys[rows][cols] = {
  32. {'1','2','3', 'A'},
  33. {'4','5','6', 'B'},
  34. {'7','8','9', 'C'},
  35. {'*','0','#', 'D'}
  36. };
  37.  
  38. byte rowPins[rows] = {9,8,7,6}; //connect to the row pinouts of the keypad
  39. byte colPins[cols] = {5,4,3,2}; //connect to the column pinouts of the keypad
  40. Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
  41.  
  42. Servo Servo1;
  43.  
  44. LiquidCrystal_I2C lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
  45.  
  46. void setup()
  47. {
  48. lcd.begin(16,2);
  49. Serial.begin(9600);
  50. lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  51. lcd.setBacklight(HIGH);
  52. Servo1.attach(servoPin);
  53. Servo1.write(0);
  54.  
  55. char string[9] = "test";
  56. char string2[6] = "hello";
  57. char all[10] = "";
  58. strcat(all, string);
  59. strcat(all, string2);
  60.  
  61. Serial.println(all);
  62. }
  63.  
  64.  
  65. void loop()
  66. {
  67. char key = keypad.getKey();
  68. char pass[5] = "";
  69. char realPass = "2601";
  70. char dataDump[2] = "";
  71.  
  72.  
  73. lcd.setCursor(0, 0);
  74. lcd.print("Enter Password:");
  75. lcd.setCursor(0, 1);
  76.  
  77. if(key != NO_KEY)
  78. {
  79. if(amount1 >= 3)
  80. {
  81. amount1 = 0;
  82. if(pass == realPass)
  83. {
  84. strcat(pass, "");
  85. lcd.setCursor(0,0);
  86. lcd.print("Correct! ");
  87. digitalWrite(greenLight, HIGH);
  88. delay(1500);
  89. digitalWrite(greenLight, LOW);
  90. }
  91. else
  92. {
  93. strcpy(pass, "");
  94. lcd.setCursor(0,0);
  95. lcd.print("Incorrect! ");
  96. lcd.setCursor(0,1);
  97. lcd.print(" ");
  98. digitalWrite(redLight, HIGH);
  99. delay(1500);
  100. digitalWrite(redLight, LOW);
  101. }
  102. }
  103. else
  104. {
  105. Serial.println(key);
  106. amount1++;
  107. strcat(pass, key);
  108. Serial.println(pass);
  109. lcd.setCursor(0,1);
  110. lcd.print(pass);
  111. }
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement