c - 16X2 LCD shield with 4x4 matrix keypad -


i have small problem. trying display characters on 16x2 lcd shield 4x4 keypad connected arduino uno. when press keypad buttons, corresponding character prints on serial monitor not dsplay. should mention after looking ascii table characters, incorrect characters being printed on lcd correspond repeated ascii characters i.e pressing 1 key prints 1111 1111, , key may print character corresponds ascii 1011 1011. characters in ascii table bottom right, top left. when press key prints once on serial monitor multiple times on lcd. post code below , link keypad , lcd shield using. on final note when print characters/words on display not keypad print fine.

code:

#include <keypad.h> #include <liquidcrystal.h> // initialize library numbers of  liquidcrystal lcd(8, 9, 4, 5, 6, 7);    const byte rows = 4; //four rows const byte cols = 4; //four columns char hexakeys[rows][cols] = { {'1','2','3','a'}, {'4','5','6','b'}, //define cymbols on buttons of keypads {'7','8','9','c'}, {'*','0','#','d'} };    byte rowpins[rows] = {13, 12, 11, 10}; //connect row pinouts of         keypad byte colpins[cols] = {9, 8, 7, 6}; //connect column pinouts of     keypad   keypad customkeypad = keypad( makekeymap(hexakeys), rowpins, colpins, rows,    cols); //initialize instance of class newkeypad  void setup() { lcd.begin(16, 2); serial.begin(9600); }  void loop() { char customkey = customkeypad.getkey();  if (customkey) { //lcd.setcursor(1,1);  lcd.print(customkey); delay(500); serial.print(customkey); } } 

lcd shield: http://www.maplin.co.uk/p/16x2-lcd-shield-for-arduino-n07dh

keypad: https://www.coolcomponents.co.uk/sealed-membrane-4-4-button-pad-with-sticker.html

thanks, hope can help.

remove if condition , try.

#include <keypad.h> #include <liquidcrystal.h> // initialize library numbers of  liquidcrystal lcd(8, 9, 4, 5, 6, 7);    const byte rows = 4; //four rows const byte cols = 4; //four columns char hexakeys[rows][cols] = { {'1','2','3','a'}, {'4','5','6','b'}, //define cymbols on buttons of keypads {'7','8','9','c'}, {'*','0','#','d'} };    byte rowpins[rows] = {13, 12, 11, 10}; //connect row pinouts of         keypad byte colpins[cols] = {9, 8, 7, 6}; //connect column pinouts of     keypad   keypad customkeypad = keypad( makekeymap(hexakeys), rowpins, colpins, rows,    cols); //initialize instance of class newkeypad  void setup() { lcd.begin(16, 2); serial.begin(9600); }  void loop() { char customkey = customkeypad.getkey(); //lcd.setcursor(1,1);  lcd.print(customkey); delay(500); serial.print(customkey);  } 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -