#include <Keypad.h>
#include<LiquidCrystal.h>
LiquidCrystal lcd(38 ,37, 42, 41, 40, 39); //16x2 lcd arduino interface pins
#define SPK 46
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte keypadKeys[8] = {
18, 17, 16, 15,
7, 6, 5, 4,
};
Keypad customKeypad(makeKeymap(keys), keypadKeys, keypadKeys + COLS, ROWS, COLS);
//Custom characters byte arrays
byte customchar[8]={
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
//Custom characters byte arrays
void fillWithCustChar(int custom)
{
for(int y=0; y<4; y++)
{
for(int x=0; x<20; x++)
{
lcd.setCursor(x,y);
lcd.write(custom);
}
}
}
void startupAnimation(char* msg)
{
for(int y=0; y<4; y++)
{
fillWithCustChar(1);
lcd.setCursor(1, y);
lcd.print(msg);
delay(500);
}
fillWithCustChar(1);
delay(500);
}
void setup() {
// put your setup code here, to run once:
pinMode(SPK, OUTPUT);
char* initText = "Dakotath Security!";
lcd.begin(20,4);
lcd.createChar(1 , customchar); //Creating custom characters in CG-RAM
lcd.clear();
startupAnimation(initText);
tone(SPK, 500*5, 1000);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
char pressedKey = customKeypad.getKey();
if(pressedKey)
{
tone(SPK, 500*5, 10);
lcd.print(pressedKey);
}
delay(10); // this speeds up the simulation
}