Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keypad.h>
- const byte ROWS = 4; //four rows
- const byte COLS = 4; //four columns
- //define the Symbols on the buttons of the keypads
- char hexaKeys[ROWS][COLS] = {
- {'1','2','3','A'},
- {'4','5','6','B'},
- {'7','8','9','C'},
- {'Y','0','N','S'}
- };
- byte rowPins[ROWS] = {7, 8, 9, 10}; //connect to the row pinouts of the keypad
- byte colPins[COLS] = {6, 5, 4, 3}; //connect to the column pinouts of the keypad
- //initialize an instance of class NewKeypad
- Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
- char code[9];
- int code_x=0;
- void printCode() {
- for(int x=0; x=8; x++) {
- Serial.print(code[x]);
- }
- }
- void setup(){
- Serial.begin(9600);
- }
- void loop(){
- char customKey = customKeypad.getKey();
- if (customKey=="N"){
- Serial.println(customKey);
- code_x=0;
- }
- else if (customKey=="Y") {
- Serial.println(customKey);
- Serial.println("invio codice...");
- printCode();
- }
- else if (customKey) {
- Serial.println(customKey);
- code[code_x]=customKey;
- code_x++;
- printCode();
- if (code_x=9) {
- code_x=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement