Hello Forum
I am using arduino atmega2560 with non touch 3.2" 480320 TFT LCD display interfaced with numeric keypad 44.
I have used following code to display the number enter through numeric keypad
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
//#include "TFTLCD.h"
#include <Keypad.h>
#include <UTFT.h>
extern uint8_t SmallFont[];
const byte ROWS = 4;
const byte COLS = 4;
char buffer;
long lastUpdate = 0;
int x;
UTFT myGLCD(CTE32HR,38,39,40,41);
char keys[ROWS][COLS] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'},
};
byte rowPins[ROWS] = {6,7,8,9}; //connect to row pinouts
byte colPins[COLS] = {10,11,12,13}; //connect to column pinouts
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(void)
{
Serial.begin(9600);
Serial.println("8 Bit LCD test!");
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}
void loop(void)
{
char key = keypad.getKey();
if (key != NO_KEY)
{
Serial.print(key);
buffer=key;
}
/*testtext(BLACK);
delay(1000); */
if((millis() - lastUpdate) > 100) // has it been >1 second since the last update?
{
testtext(BLACK); // update display
lastUpdate = millis();
x=x+8; // remember the time
}
}
//int y = (10*x);
// for TFT screen display letters
void testtext(uint16_t color)
{
myGLCD.fillScr(CYAN);
// myGLCD.setCursor(50, 20);
// myGLCD.setTextColor(RED);
// myGLCD.setTextSize(2);
myGLCD.print("HI TEXTS BELOW" , CENTER ,10);
// myGLCD.setCursor(x, 50);
// myGLCD.setTextSize(4);
myGLCD.print(buffer , CENTER, 30);
}
But when I have enter the number from keypad display is showing some junk value.
Please suggest how to display the correct number enter from keypad.