Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

store the keypad press sequence as a data- arduino

Status
Not open for further replies.

rajeetharan

Newbie level 3
Newbie level 3
Joined
Jul 28, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
27
i want to display keypad presses in tft screen ( like calculator screen ).
and want store that key press sequence ( assume 10 keypad press ).
how can i drive this ?





Code:
#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>

const byte ROWS = 5;
const byte COLS = 4;
char buffer;
long lastUpdate = 0;
int x;

TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

char keys[ROWS][COLS] =
{
  {'1','6','A','D'},
  {'2','7','B','E'},
  {'3','8','C','F'},
  {'4','9','X','Y'},
  {'5','0','Z','R'},
 
};

byte rowPins[ROWS] = {40,39,38,37,36}; //connect to row pinouts
byte colPins[COLS] = {32,33,34,35}; //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!");
  tft.reset();
  tft.initDisplay();

}

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)
{
  tft.fillScreen(CYAN);
  tft.setCursor(50, 20);
  tft.setTextColor(RED);
  tft.setTextSize(2);
  tft.println("HI TEXTS BELOW");
  
 
  tft.setCursor(x, 50);
  tft.setTextSize(3);
  tft.print(buffer);

}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top