#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd (0x27, 6, 2);
const byte r = 4;
const byte c = 4;
byte rp[r] = {5, 4, 3, 2};
byte rc[c] = {A3, A2, A1, A0};
byte cc=0;
char keys[r][c] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'.', '0', '=', 'D'}
};
Keypad keypad = Keypad(makeKeymap(keys), rp, rc, r, c);
// make some custom characters:
byte heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};
byte smiley[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b10001,
0b01110,
0b00000
};
byte frownie[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b00000,
0b01110,
0b10001
};
byte armsDown[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};
byte armsUp[8] = {
0b00100,
0b01010,
0b00100,
0b10101,
0b01110,
0b00100,
0b00100,
0b01010
};
void setup() {
lcd.begin(16,2);
lcd.setCursor(1,0);
lcd.init();
lcd.backlight();
// create a new character
lcd.createChar(0, heart);
lcd.createChar(1, smiley);
lcd.createChar(2, frownie);
lcd.createChar(3, armsDown);
lcd.createChar(4, armsUp);
}
void loop() {
int sensorReading = analogRead(A4);
char key = keypad.getKey();
if (key == '1') {
lcd.setCursor(0,0);
lcd.clear();
lcd.print("Aldo");
lcd.write(byte(4));
lcd.setCursor(0,1);
lcd.print("Quinsha");
lcd.write(byte(1));
}
else if (key == '2') {
lcd.setCursor(0,0);
lcd.clear();
lcd.print("Aaron");
lcd.write(byte(2));
lcd.setCursor(0,1);
lcd.print("Kulbert");
lcd.write(byte(3));
}
else if (key == '3') {
lcd.setCursor(0,0);
lcd.clear();
lcd.print("Yitro");
lcd.write(byte(4));
lcd.setCursor(0,1);
lcd.print("Valentina");
lcd.write(byte(0));
}
else if (key == '4') {
lcd.setCursor(0,0);
lcd.clear();
lcd.write(byte(3));
lcd.write(byte(0));
lcd.write(byte(4));
for (int i = 0 ; i < 16; i++) {
lcd.scrollDisplayRight();
delay(150);
}
}
else if (key == '0') {
lcd.setCursor(0,0);
lcd.clear();
}
}