element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Interfacing keypad and TFT LCD with Arduino Uno
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 0 replies
  • Subscribers 400 subscribers
  • Views 309 views
  • Users 0 members are here
Related

Interfacing keypad and TFT LCD with Arduino Uno

Former Member
Former Member over 11 years ago

Hi, i am new to arduino and i need some help on how to interface a 4x3 keypad and a TFT lcd with arduino uno. I want to display the values i pressed on the keypad to the lcd. Can someone help me with that?

Here is my code:

 

#include <Keypad.h>

#include <TFT.h>

#include <SPI.h>

 

 

// pin definition for the Uno

#define cs   10

#define dc   9

#define rst  8

 

 

// create an instance of the library

TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen

char sensorPrintout[4];

 

 

const byte ROWS = 2; //four rows

const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {

  {'1','2','3'},

  {'*','0','#'}

};

byte rowPins[ROWS] = {2, 3}; //connect to the row pinouts of the keypad

byte colPins[COLS] = {5, 6, 7}; //connect to the column pinouts of the keypad

 

 

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

 

 

void setup(){

  Serial.begin(9600);

  // Put this line at the beginning of every sketch that uses the GLCD:

  TFTscreen.begin();

  // clear the screen with a black background

  TFTscreen.background(0, 0, 0);

 

 

  // write the static text to the screen

  // set the font color to white

  TFTscreen.stroke(255, 255, 255);

  // set the font size

  TFTscreen.setTextSize(2);

  // write the text to the top left corner of the screen

  TFTscreen.text("Sensor Value :\n ", 0, 0);

  // ste the font size very large for the loop

  TFTscreen.setTextSize(5);

}

 

 

void loop(){

  char key = keypad.getKey();

 

 

  if (key != NO_KEY){

    Serial.println(key);

  }

  TFTscreen.text(key);

  // Read the value of the sensor on A0

  String sensorVal = String(analogRead(A2));

 

 

  // convert the reading to a char array

  sensorVal.toCharArray(sensorPrintout, 4);

 

 

  // set the font color

  TFTscreen.stroke(255, 255, 255);

  // print the sensor value

  TFTscreen.text(sensorPrintout, 0, 20);

  // wait for a moment

  delay(250);

  // erase the text you just wrote

  TFTscreen.stroke(0, 0, 0);

  TFTscreen.text(sensorPrintout, 0, 20);

}

  • Sign in to reply
  • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube