//
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd = LiquidCrystal(2, 3, 4, 5, 6, 7);
const byte ROWS = 4; //4 Lignes (4 Lines, 4 rows)
const byte COLS = 3; //3 Colonnes (3 columns)
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
// FR: Connecté sur les lignes du KeyPad (L1, L2, L3, L4)
byte rowPins[ROWS] = {14, 15, 16, 17};
// FR: Connecté sur les colonnes dy KeyPad (C1, C2, C3)
byte colPins[COLS] = {18, 19, 13};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int cursorColumn = 0;
void setup(){
lcd.begin(16, 2);
pinMode(12, INPUT_PULLUP); // la broche led est en sortie
}
void loop(){
char key = keypad.getKey();
if (key) {
lcd.setCursor(cursorColumn, 0); // move cursor to (cursorColumn, 0)
lcd.print(key); // print key at (cursorColumn, 0)
cursorColumn++; // move cursor to next position
if(cursorColumn == 17) { // if reaching limit, clear LCD
lcd.clear();
cursorColumn = 0;
lcd.print(key);
cursorColumn = 1;
}
}
if (digitalRead(12)==LOW) {
lcd.clear();
cursorColumn = 0;
}
}