Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Arduino passcode with lcd screen

a guest Mar 31st, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  56.  
  57. void loop()
  58. {
  59.   char key = keypad.getKey();
  60.   String pass = "";
  61.   String realPass = "2601";
  62.  
  63.   lcd.setCursor(0, 0);
  64.   lcd.print("Enter Password:");
  65.   lcd.setCursor(0, 1);
  66.  
  67.   if(key != NO_KEY)
  68.   {
  69.       if(amount1 >= 4)
  70.       {
  71.         amount1 = 0;
  72.         if(pass == realPass)
  73.         {
  74.           strcpy(pass, "");
  75.           digitalWrite(greenLight, HIGH);
  76.           delay(1500);
  77.           digitalWrite(greenLight, LOW);
  78.         }
  79.         else
  80.         {
  81.           pass = "";
  82.           lcd.setCursor(0,0);
  83.           lcd.print("Correct!");
  84.           lcd.setCursor(0,1);
  85.           lcd.print("");
  86.           digitalWrite(redLight, HIGH);
  87.           delay(1500);
  88.           digitalWrite(redLight, LOW);
  89.         }
  90.       }
  91.       else
  92.       {
  93.         Serial.println(key);
  94.         amount1++;
  95.         oass = pass + key;
  96.         lcd.setCursor(0,1);
  97.         lcd.print(pass);
  98.       }
  99.    }
  100. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top