Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <Wire.h> //Reikalingas ekranui
  2. #include <LiquidCrystal_I2C.h> // Reikalingas ekranui
  3. #include <Keypad.h> // reikalingas klaveturai
  4.  
  5. const byte ROWS = 4; //four rows
  6. const byte COLS = 4; //four columns
  7.  
  8. //define the cymbols on the buttons of the keypads
  9. char hexaKeys[ROWS][COLS] = {
  10. {'1', '2', '3', 'A'},
  11. {'4', '5', '6', 'B'},
  12. {'7', '8', '9', 'C'},
  13. {'*', '0', '#', 'D'}
  14. };
  15. byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
  16. byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keyp
  17.  
  18. Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
  19. int slaptSimbol = 0;
  20. int slaptazodis[4];
  21. int slaptazodisDAUG[4] = {1035, 58, 12, 158};
  22. int slapt = 0;
  23.  
  24. char customKey = customKeypad.getKey();
  25. int sk = customKey - '0';
  26.  
  27.  
  28. //#define BACKLIGHT_PIN 13
  29.  
  30. LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
  31.  
  32.  
  33. void setup()
  34. {
  35. Serial.begin(9600);
  36. lcd.begin(16, 2);
  37. lcd.clear();
  38. Serial.write("Uzkrovem setup");
  39. prisijungti(4, 5555);
  40. }
  41.  
  42. void loop()
  43. {
  44. }
  45.  
  46. bool prisijungti(int SLAPTAZODZIOilg, int SLAPTAZODIS) { // Bandyk ta informacija per cia ideti
  47. // SLAPTAZODIS tai tas tavo galutinis, sudaugintas numeris (6315)
  48. // SLAPTAZODZIO_KUODOTE[] tai tie skaiciai kuriuos daugins (1035, 58, 12, 158)
  49. lcd.setCursor(2, 0);
  50. lcd.print("PRISIJUNGIMAS");
  51.  
  52. int bandomasSlapt = 0;
  53.  
  54. Serial.write("Pradejom krauti funkcija");
  55. for (int i = 0 ; i < SLAPTAZODZIOilg ; i++ ) {
  56. while (customKey) {
  57. slaptazodis[slaptSimbol] = sk;
  58. Serial.write("Paspaudem skaiciu");
  59. }
  60. // Cia isivedi ta skaiciu i masyva ir sudaugini ar dar kokia nesamone sugalvoji
  61. bandomasSlapt += slaptazodis[slaptSimbol] * slaptazodisDAUG[slaptSimbol] + slapt;
  62.  
  63. lcd.setCursor(6 + slaptSimbol, 1);
  64. lcd.write("*");
  65. }
  66.  
  67. if(bandomasSlapt == SLAPTAZODIS)
  68. {
  69. lcd.setCursor(11, 1);
  70. lcd.print("OK");
  71. Serial.write("Slaptazodis Geras");
  72. return true;
  73. }
  74. else
  75. {
  76. lcd.setCursor(11, 1);
  77. lcd.print("NO");
  78. Serial.write("Slaptazodis blogas");
  79. return false;
  80. }
  81. return true;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement