Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3227970
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:38:13+00:00 2026-05-17T16:38:13+00:00

I have a device which has got 9 keys just like an ordinary mobile

  • 0

I have a device which has got 9 keys just like an ordinary mobile phone.
I want to print normal alphabets like ABCD using these 9 keys exactly the way mobile phones let you do it.

This is an embedded system programming project. I am unable to figure out the logic to implement this functionality.

I am detecting keys by polling and not by interrupt.

Can someone help? I will appreciate if you can point out related resources as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:38:14+00:00Added an answer on May 17, 2026 at 4:38 pm

    Here is a little keyboard decoding demo that should get you well on your way. You’ll need to rewrite the key scanning routine for your hardware. In addition, there will be some kind of timeout needed to select the same digit twice in a row. You should also have little trouble figuring out how to add support for capitalization, punctuation, and meta keys…

    #include <stdio.h>
    
    #define NUM_KEYS 10
    #define NUM_PHASES 6
    
    char KeyMap[NUM_KEYS][NUM_PHASES] =
        {   { '0',   0,   0,   0,   0,   0 },
            { '1',   0,   0,   0,   0,   0 },
            { '2', 'A', 'B', 'C',   0,   0 },
            { '3', 'D', 'E', 'F',   0,   0 },
            { '4', 'G', 'H', 'I',   0,   0 },
            { '5', 'J', 'K', 'L',   0,   0 },
            { '6', 'M', 'N', 'O',   0,   0 },
            { '7', 'P', 'Q', 'R', 'S',   0 },
            { '8', 'T', 'U', 'V',   0,   0 },
            { '9', 'W', 'X', 'Y', 'Z',   0 }    };
    
    char KeyGet()
    {
        char key;
    
        /* do whatever it takes to scan your
           keyboard and return the _numeric_ digit. */
    
        /* for this test simulate with console input */
        key = getc(stdin);
    
        if ((key >= '0') && (key <= '9'))
        {
            key -= 0x30;
        }
        else
        {
            key = 0;
        }
    
        return key;
    }
    
    char DecodeKey(char NewKey, char *pOldKey, int *pPhase)
    {
        char ch = 0;
    
        /* Validate Phase */
        if ((*pPhase < 0) || (*pPhase >= NUM_PHASES))
        {
            *pPhase = 0;
        }
    
        /* see if a different key was pressed than last time */
        /* if it was then restart the phase counter */
        if (NewKey != *pOldKey)
        {
            *pPhase = 0;
            *pOldKey = NewKey;
        }
    
        /* Validate Key */
        if ((NewKey >= 0) && (NewKey < NUM_KEYS))
        {
            ch = KeyMap[(int)NewKey][*pPhase];
    
            /* if the phase position is NULL, just get the numeric digit */
            if (ch == 0)
            {
                *pPhase = 0;
                ch = KeyMap[(int)NewKey][*pPhase];
            }
    
            /* bump the phase */
            ++(*pPhase);
    
            if (*pPhase >= NUM_PHASES)
            {
                *pPhase = 0;
            }
        }
    
        return ch;
    }
    
    int main()
    {
        char nk;        /* new key */
        char ok = 0;    /* old key */
        char c;         /* resulting character */
        int phase = 0;  /* tracks the key presses */
    
        while (1)
        {
            /* get a key */
            nk = KeyGet();
    
            /* convert it to a character */
            c = DecodeKey(nk, &ok, &phase);
    
            if (c != 0)
            {
                printf("%c", c);
            }
        }
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am porting PC game to iPad which has ton of graphic assets (over
I have some html that creates a dropdown list. The list has text values
I'm building a Webapp that uses OpenId to authenticate users, like Stackoverlfow does. There
I have an iPad app that is set to start in landscape mode. From
I have the following requirements: Keeping a list of users on disk for future
I 'm trying to read and display contacts from phone book in android. My
Our embedded systems programmer has developed the shell of a virtual serial port driver
I am attempting to communicate with a rather specific USB device and developing both
I am a little confused about where to get (or create) a distribution profile
I am using the function below to capture an image on a different form.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.