Hi, this is my first post and I hope somebody here would be able to help me.
For this project I am using an arduino uno, a 4x4 keyboard, and an LCD screen.
So I am trying to make a project where the user can enter a table number on the keyboard, and it apears on the LCD screen. (see the attachment)
But I'm still struggling.
I want it so that the number for the table above can only be entered or deleted after the user presses 'A'.
And only after they press 'B', they can enter or delete the number below. But I can't figure it out...
I would also like to add 2 LED lights. When the user is entering the first number, the first LCD light burns.
When they are entering the second number, the second LCD light burns. They should be able to constantly chance the number they want. But I think I don't have enough pins.. unless if I use another LCD screen maby, but this is the only one that I can use in Tinckercad.com.
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
byte ArrowDown[8] = {
B00100,
B00100,
B00100,
B00100,
B11111,
B01110,
B00100,
};
byte ArrowUp[8] = {
B00100,
B01110,
B11111,
B00100,
B00100,
B00100,
B00100,
};
long input = 0;
char customKey;
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 rowPins[ROWS] = {7,6,5,4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {3,2,1,0}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup()
{
lcd.createChar(0, ArrowUp);
lcd.createChar(1, ArrowDown);
lcd.begin(16, 2);
for(int i=0;i<=3;i++);
lcd.setCursor(0,0);
lcd.print("TABLE : ");
lcd.setCursor(5,0);
lcd.write(byte(0));
lcd.setCursor(0,1);
lcd.print("TABLE : ");
lcd.setCursor(5,1);
lcd.write(byte(1));
lcd.setCursor(0, 0);
}
void loop()
{
customKey = customKeypad.getKey();
switch(customKey)
{
case '0' ... '9': // This keeps collecting the first value until a operator is pressed "+-*/"
lcd.setCursor(8,0);
input = input * 10 + (customKey - '0');
lcd.print(input);
break;
case '*':
input = 0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TABLE : ");
lcd.setCursor(5,0);
lcd.write(byte(0));
lcd.setCursor(0,1);
lcd.print("TABLE : ");
lcd.setCursor(5,1);
lcd.write(byte(1));
break;
}
}