#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int i = 0;
int m = 0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
{'D','C','B','A'},
{'#','9','6','3'},
{'*','7','4','1'},
{'0','8','5','2'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char key = keypad.getKey();
void setup(){
lcd.begin(16,2);
lcd.backlight();
Serial.begin(9600);
}
void loop(){
lcd.setCursor(0,0);
lcd.print("Password: ");
lcd.setCursor(0,1);
byte pwtrue[8] = {1,2,3,4,5,6,7,8};
int pwtrial[8];
while (i<8) {
key = keypad.getKey();
if (key) {
pwtrial = key;
- Serial.print(i);*
- i = i + 1;*
_ Serial.println(pwtrial*);*_
* }*
* }*
* while (m<8) {*
* if (pwtrial[m] != pwtrue[m]) {*
* lcd.print("Wrong Password");*
* m = 8; *
* }*
* m = m + 1;*
* }*
}
This is my code right now and I'm trying to get the keypad.getLey() into pwtrial*. However, this is the results on the serial. I also put the variable i and m as global variables otherwise the loop keeps on restarting.*
0 -256
1 256
2 -16126
3 8703
4 770
5 513
6 1
7 513
The left numbers are i, and the numbers on the right are pwtrial from 1 - 7.