I have a small project that i want to show my keypad pressed on my GLCD but when i pressed keypad, even on serial it is fines but on GLCD it can't show my characters. Could you tell me what the problem and what should i do to solve!. my GLCD library is BasicGLCD!
#include <Keypad.h> #include <EEPROM.h> #include <basicGLCD.h> basicGLCD GLCD; /long four = 0; long three = 0; long two = 0; long one = 0; / int adress = 0; // gia tri dia chi luu du lieu const byte rows = 4; //so hang const byte columns = 4; // so cot
int holdDelay = 100; // thoi gian tre de xem la nhan 1 nut de tranh nhieu~ int n = 3; // int state = 0; // neu state=0 khong nhan, state=1 nhan thoi gian nho , state = 2 nhan giu lau char key = 0; int i=1; //dinh nghia cac gia tri tra ve char hexaKeys[rows][columns] = { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'}, };
byte rowPins[rows] = {4, 5, 6, 7}; // cách nói chan Arduino byte columnPins[columns] = {12, 13, 2, 3};// cách nói chan Arduino
//cài đặt thư viện keypad Keypad keypad = Keypad(makeKeymap(hexaKeys), rowPins, columnPins, rows, columns); ////////////////////////////////////////////////////// void setup() { Serial.begin(9600);//bật serial, baudrate 9600 // GLCD.setCursor(4, 0); //GLCD.sendString("WELCOME....");
////// GLCD.setDataPins(23,25,27,29,31,33,35,37); GLCD.setRSPin(A2); GLCD.setCSPins(A0, A1); GLCD.setENPin(A4); GLCD.setRWPin(A3); if(GLCD.init() != 1) { Serial.println("You have to set all pins"); return 0; } else { GLCD.sendString(" WELCOME "); GLCD.setCursor(10, 0); delay(500); GLCD.clear();} //////////////////////////////////////////
GLCD.setCursor(0, 1); GLCD.sendString("Loai IVT: "); GLCD.setCursor(0, 2); GLCD.sendString("TG mau : "); GLCD.setCursor(0, 3); GLCD.sendString("CSCD :");
} ////////////////////////////////////////// void loop() { char temp = keypad.getKey(); if ((int)keypad.getState() == PRESSED) { if (temp != 0) { key = temp; } //xem kq if(temp) {if(temp == '+') {GLCD.clear();} if(temp == '=') {i=i+1;} GLCD.setPage(RIGHT); GLCD.setCursor(5,i); GLCD.sendData(temp); ; } delay(500); } }