I am currently using a 4x4 keypad in my project to enter the information to display on my LCD 16x2 my keypad and program with:
- a button that erases all entries on the screen.
- another that validates the entries.
Now I would like to program another 3 button that will allow us to:
- Move the cursor to the left.
- Move the cursor to the right.
- Delete a character. Note that the user can move between the previously entered characters and delete one before moving the cursor again to the right to continue his text.
Any help will be appreciated!
Cordially...
that is my code:
#include <SPI.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27,16,2);
/*Le Clavier*/
const byte numRows= 4;
const byte numCols= 4;
char keymap[numRows][numCols]= {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'S'},
{'7', '8', '9', 'C'},
{'<', '0', '>', 'V'}
};
byte rowPins[numRows] = {5,4,3,2};
byte colPins[numCols] = {9,8,7,6};
//initialiser le clavier
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
void setup() {
//Initialiser l'ecran LCD
lcd.init();
lcd.backlight();
SPI.begin();
lcd.print("Entrez le");
lcd.setCursor(0,1);
lcd.print("montant");
delay(3000);
lcd.clear();
lcd.blink();
}
void loop() {
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY){
if(keypressed == '*'){
}
else if(keypressed == 'C'){
lcd.clear();
}
else if(keypressed == 'V'){
lcd.clear();
lcd.print("Passer votre");
lcd.setCursor(0,1);
lcd.print("carte!");
lcd.noBlink();
}
else{
lcd.print(keypressed);
}
}
}