EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / Keypad Interface Using C

Keypad Interface Using C

|

Microcontroller › 8051 › Keypad Interface Using C

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 8 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 23, 2013 at 12:11 pm #2655
    Shan
    Participant

    Hi everyone..

    I need c-program to scan the keypad ad send the result to first seriat port.

    Here P1.0 to P1.3 should represent columns and

    P2.0 to P 2.3 should represent rows.

    This is where im stuck now.

     

    # include <reg51.h> // Header for AT89C51

     

     

    sbit R0=P2^0;   // Row 1 of the Keypad

    sbit R1=P2^1;   // Row 2 of the Keypad

    sbit R2=P2^2;   // Row 3 of the Keypad

    sbit R3=P2^3;   // Row 4 of the Keypad

    sbit C0=P1^0;   // Column 1 of the Keypad

    sbit C1=P1^1;   // Column 2 of the Keypad

    sbit C2=P1^2;   // Column 3 of the Keypad

    sbit C3=P1^3;   // Column 4 of the Keypad 

     

    int row_read();   // Row Read Function Declaration

     

    int col_read();    // Colum Read Function Declaration

     

    void delay(int);   // Dealy Function Declaration

     

    void delay(int a)

    {   int i;  

     for(i=0;i<a;i++);  }

     

    int row_read ()// Row Read Function Define

     {           

    P2=0x0F;      // Set The Higher Nibble High

      if(R0==1) 

    { return(1); } 

    else if(R1==1) 

    { return(2); } 

    else if(R2==1)

     { return(3); } 

    else if(R3==1)

     { return(4); } 

    delay(10000);  }

     int col_read ()// Column Read Function Define

     {

               P1=0x0F;    // Set The Lower Nibble High

     if(C0==1) 

    {  return(1); } 

    else if(C1==1) 

    { return(2); }

     else if(C2==1) 

    { return(3); }

     else if(C3==1) 

    { return(4); } 

    delay(10000); 

    } 

    main ()  {   int j=0,i=0;  

    while(1)

    Now here what should i write to call the rows and cloumns scanning functions + to get output..??

     

     

    November 28, 2013 at 1:14 pm #10667
    AJISH ALFRED
    Participant

    Hi Shan,

    Please post the circuit diagram

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • How to power up two stereo audio amplifiers from a single source of power supply August 13, 2022
  • WXmeteo in APRS at 144.8MHz project schematic question August 13, 2022
  • uc3843 Buck-boost August 13, 2022
  • Add a low power indicator LED August 13, 2022
  • ESP32/Arduino OTA problems August 13, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools