Hi! I am trying to create a program where I press a character on a keypad and then it will appear on the LCD. Everything works fine but one thing. I am trying to make the '#' button on my keypad clear what is on the LCD but it creates a weird squiggle character. I do not think this is a circuit issue as I have tried clearing the LCD in another program and that works fine. Any help will be appreciated.
(Yes, my code is sloppy)
#include <Key.h>
#include <Keypad.h>
#include <LiquidCrystal.h>
const byte numRows= 4;
const byte numCols= 4;
char keymap[numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[numRows] = {29,28,27,26};
byte colPins[numCols]= {25,24,23,22};
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
void setup() {
lcd.begin(16,2);
Serial.begin(9600);
}
void loop() {
char keypressed = myKeypad.getKey();
if (keypressed == '#') {
lcd.clear();
Serial.println("clear");
}
else if (keypressed != NO_KEY) {
lcd.print(keypressed);
Serial.println("character");
}
}