// ELTR2302.Section2.Part4
// Created by H.V. Wallbanger on January2022
// This program uses an LCD and 4x4 Matrix Keypad
// ==============================================
// #include/#define/Variable Definition Section
// ==============================================
#include <LiquidCrystal.h>
//LiquidCrystal(RS,RW,EN,d0,d1,d2,d3,d4,d5,d6,d7)
LiquidCrystal LCD(24,23,22,37,36,35,34,33,32,31,30);
// BYT0 BYT1 BYT2 BYT3 BYT4 BYT5 BYT6 BYT7
byte pac0[8] = {0x0E,0x1F,0x17,0x1F,0x1C,0x1F,0x1F,0x0E};
byte pac1[8] = {0x0E,0x1F,0x17,0x1E,0x18,0x1E,0x1F,0x0E};
byte pac2[8] = {0x0E,0x1F,0x16,0x1C,0x18,0x1C,0x1E,0x0F};
byte pac3[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
byte pac4[8] = {0x0E,0x1F,0x17,0x1E,0x18,0x1E,0x1F,0x0E};
byte pac5[8] = {0x0E,0x1F,0x17,0x1F,0x1C,0x1F,0x1F,0x0E};
byte pac6[8] = {0x0E,0x1F,0x17,0x1F,0x1F,0x1F,0x1F,0x0E};
char Name[] = "Harvey Wallbanger";
int pos = 0, count = 0;
//================================================================================
void setup()
{
//Define and setup the LCD display here
LCD.begin(20,4); delay(2); //Set a 20Column;4Row LCD and wait to process
LCD.noAutoscroll();
//Create ASCII characters
LCD.createChar(0,pac0);
LCD.createChar(1,pac1);
LCD.createChar(2,pac2);
LCD.createChar(3,pac3);
LCD.createChar(4,pac4);
LCD.createChar(5,pac5);
LCD.createChar(6,pac6);
//LCD.createChar(7,pac7);
}
//================================================================================
//This is the main program loop.
void loop()
{
LCD.clear(); delay(2);
LCD.setCursor(2,1); //Set cursor to column 2 row 1 (2nd line of LCD)
LCD.print(Name);
delay(500);
for(pos = 0; pos < 19; pos++)
{
for(count = 0; count<4; count++)
{
delay(200);
LCD.setCursor(pos,1); //Set pacman to one position before the name
LCD.write(byte(count)); //Open mouth to get ready to move
}
for (count = 4;count < 7; count++)
{
LCD.setCursor(pos+1,1); //Move pacman to next position decimating the letter
LCD.write(byte(count)); //moved and closed mouth
delay(200);
}
}
}