#include <Keypad.h>
#include <Servo.h>
#define ROW_NUM 4 // four rows
#define COLUMN_NUM 4 // four columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte pin_rows[ROW_NUM] = {9, 8, 7, 6}; // GIOP19, GIOP18, GIOP5, GIOP17 connect to the row pins
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; // GIOP16, GIOP4, GIOP0, GIOP2 connect to the column pins
// il faut penser à changer ces valeurs car sur esp32 ce sont pas les mêmes broches !
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.attach(10); // attaches the servo on pin 10 to the servo object
// il faut changer aussi car sur esp32 c'est pas la même broche !
}
void loop() {
char key = keypad.getKey();
if (key == 'D') {
myservo.write(90);// rotates the servo to 90 degrees
}
if (key == '*') {
myservo.write(0); // rotates the servo to 0 degrees
}
//if (key) {
// Serial.println(key); cette partie permet d'afficher dans le moniteur de serie quelle touche du clavier est saisie
//}
}