searching for a letter keypad

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello!
I am working with ATMEGA 8535 Ic ,I use codevision ,and a 4*3 keypad for numbers ONLY.
I need a method,that I can use to print strings and characters on the LCD from keypad.
Is that right that I use that keypad ,or I must build a special keypad??
and if I used a special keypad what is the C code shall I use??
thanks in advance. :?: :?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read this thread first.

https://www.avrfreaks.net/index.p...

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello,
I want each button in my keypad to print at least 3 letters(each press types one letter),what method shall I use?
hint: 1-it has 12 buttons only.
2-the LCD is 2*16,so I need the word
occupies 16 places only in LCD.
3-the letters I want is English.
4-I am using C codes not assembly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nice of you to give hints :P

Ross's link still applies...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do not mean any thing ,I just trying to explain my case as mr/jim said before..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abohmaid wrote:
I do not mean any thing ,I just trying to explain my case as mr/jim said before..
If you read and understand the thread that I provided, you will see that the method to use is the same as used on mobile/cell phones for creating a SMS message where 3 letters of our alphabet (I do not know if you have Arabic character telephones) are printed next to each number key. For example on the number 1 key we have "abc". One press of "1" would select "a", two quick presses would select "b", etc.

So to enter "abu jamal" you would use the 1, 8, #, 5 and 6 keys with suitable time pauses to select the correct letter under each number.

Is that clear?

Maasalamma,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Like texting on a cellphone.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hahahaha...
Nice word (maasalamma),although I have spent few seconds to translate it,
I know the way that cell phones are using,but I do not know the C code shall I use to apply this..

maasalamma means ==> مـع الســـلامــة

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I know the way that cell phones are using,but I do not know the C code shall I use to apply this..

Work in small steps:
0. Learn how to write and program the simplest application (blinking a LED) into an AVR.
1. Learn how to read a button press.

2. Learn how to read a button press reliably (eg with "switch debouncing" - a subject in itself.)

3. Learn how to use timers, if item #2 didn't get you there).

4. Learn how to display characters somewhere so that you can check that the "typing code" you are about to create actually works. This might mean UART comms to a PC, or an LCD display attached to your AVR or... This in itself will be a numbered list with five to ten small steps to take.

5. Use item #3 to create a time base so that you can detect and discern between two quick presses of the "3" button (which would mean a "d"), and two presses of the "3" button with a longer break in between (which would mean "cc"). Now you are starting to get somewhere.

6. Do all the work for the whole alphabet, which is just a mechanical expansion of item #5 with little thought needed.

7. Now work out how you want to enter numbers. Cell phones do it by holding down a button for an extended period of time, so now you need to tinker with measuring time that you learned in item #3 again.

By this time I'm sure that you have a decent list of new features that you didn't think of when starting out. Work on those. Somewhere around item #27, yet unknown, you are about to get something working.

All (good) embedded engineers work like this. Small steps. Divide and conquer. Solve a big problem by solving a lot of small problems. While they might seem extremely smart, and able to have everything re a complex system in their short-term memory this is just a mirage. They are swapping a lot of small problems in and out of their short term memory. Learn how to do this and you will have taken one step towards being a decent embedded engineer.

Think of it as building a house. You have an overall picture but not all the details all of the time. While working on one piece of the building you have the details for that piece, but you don't think about other parts details.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abohmaid wrote:
hahahaha...
Nice word (maasalamma),although I have spent few seconds to translate it,

maasalamma means ==> مـع الســـلامــة

Yes but I never learned to write Arabic :lol:

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think that you have "gotten it".

Any key can be used to generate any character. Even UTF16 or UTF32 characters.

Suppose that one key has the mark "2" on it. You can write the code that makes an "X" or an "a" or "Nuun" or an "o" with an umlaut. Or a "2". Its all up to you.

The keypad is nothing more than a set of switches that are arranged in rows and columns; When you push the "2" button, it connects one of the rows to one of the columns. You have to write the code to read this condition in the keypad. Then, according to the position and what came before, you create a character. What came before might be a certain number of key presses in a specific time interval. Or, it might be a sequence of other keys in a certain order. Its all up to you!

I don't know of any "libraries" to do this, but there might be somewhere out there on the net. But, you would be far better served learning the basics, then figure out for your self how to do it.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok ...
I think I gotten it.
Thank you all for help and giving advice.
In shaa Allah..I will try.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello..
I wish you all ok..
I am still trying to get strings from my keypad,and finally I have wrote a C code which certify my need ..
My need was..How to make single button in the keypad gives you more letters as a string>>by pushing it some pushes..
But I have an error as Codevision says...,
(missing '}' and
Can some one find this error and tell?? :roll:
thanks in advance
al salam alikom. [b]

This is the code:

#asm
.equ __lcd_port=0x12 ;portd
#endasm

#include 
#include 
#include 

int sec=15625;  //1 second delay
char str[16];
char ALPHA[26]={"A","B","C","D","E"};  // 1 st mistake
int i=0;
int n=0;
interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{
 str[i]=ALPHA[n];
 i++;
 lcd_gotoxy(i,0);
 }
void main(void)
{
  TCCR1A=0X03;  
  #asm
  ('sei')   
  #endasm
  for(n=0;n<=3;n++)
  {
  if(!PINC.0)
  {
   OCR1A=sec;    // 1 second delay
   lcd_init(16);
   lcd_puts(ALPHA[n]);  //2 nd mistake
   if(n==3){n=0;}
   }
   }
   } 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

you could do that yourself.

1) use indenting, that will make your code more readable and also makes you find this kind of error faster, but also makes you see that there is something wrong with the number of {}

In each function check how many { you have and then count the number of } you have

is there no need for an interrupt library in codevision???
if yes, then I miss that.
It also should provide an sei() function that you can use.
I do not thing you have tested this code.....
I also miss a couple of volatile declarations....

regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the extra } is the least of your worries here. First off, your main loop will run to completion if the user holds down a key (you only reset n if PINC.0 is 0).

Next, you're using the timer interrupt just to reset the screen position, the compiler will probably optimize n to 0 (as pointed out above n needs to be volatile). This is the only place you use str[], what is the aim with that line? There are more issues to deal with but, before fixing those, this code isn't going to do what you want it to. I'd get the structure sorted and then worry about the syntax were I you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that this is a lot more readable!

#asm
    .equ __lcd_port = 0x12	;portd
#endasm
#include 
#include 
#include 
int sec = 15625;                //1 second delay
char str[16];
char ALPHA[26] = { "A", "B", "C", "D", "E" };   // 1 st mistake
int i = 0;
int n = 0;
interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{
    str[i] = ALPHA[n];
    i++;
    lcd_gotoxy(i, 0);
}
void main(void)
{
    TCCR1A = 0X03;
#asm
    ('sei')
#endasm
        for (n = 0; n <= 3; n++) {
        if (!PINC .0) {
            OCR1A = sec;        // 1 second delay
            lcd_init(16);
            lcd_puts(ALPHA[n]); //2 nd mistake
            if (n == 3) {
                n = 0;
            }
        }
    }
}

You have the wrong syntax. You need single quotes.

char ALPHA[26]={'A','B','C','D','E'};  // single quotes

You still have to get your logic correct. However you may find your own code easier to follow if it is neatly layed out.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your replies ,one of the warnings have been corrected,but still the second one that I do not understand what the codevision means by this:
Error: D:\AVR codes\try for typing leters.c(32): function argument #1 of type 'unsigned char' is incompatible with
required parameter of type 'unsigned char *'
:?: :wink:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lcd_puts() wants you to pass it a STRING of chars, you are passing it a single CHAR. That's what you are being warned about.

Use something like:

char * ALPHA[26]={"A","B","C","D","E"};
...
lcd_puts(ALPHA[n]);

or maybe:

char ALPHA[26]={'A','B','C','D','E'};
char out_string[2];
...
out_string[0] = ALPHA[n];
out_string[1] = 0;
lcd_puts(out_string);

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
try for typing leters.c
It's also a good idea to avoid spaces in file names.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok.thank you again ..I modified the code and it is now working with some additives .
but when I put the simulation on Proteus,it did not worked well,it does not accept pushes from the push button...and this is the modified code:

#asm
.equ __lcd_port=0x12 ;portd
#endasm

#include 
#include 

int sec=80155;
char str[16];
char ALPHA[5]={'A','B','C','D','E'};  // single quotes
int i=0;
int n=0;
interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{
 str[i]=ALPHA[n];
 i++;
 lcd_gotoxy(i,0);
 }
void main(void)
{
       lcd_init(16);
       lcd_putsf("Ready");
  TCCR1A=0X03;  
         #asm
         sei   
         #endasm
  for(n=0;n<=3;n++)
  {
     if(PINC.0==0)
     {
       OCR1A=sec;    // 1 second delay
       lcd_init(16);
       lcd_puts(str);
       if(n==3){
                n=0;
         }
       }
     }
   }

:wink:

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying but still not respoding...any one know why??!! :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

when I put the simulation on Proteus,it did not worked well

Since you have a Proteus license, maybe ask their support? :twisted:

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello;
I wish you all in a good mood,
I tried an other way for gaining letters to my AVR chip this way is using IC MM74922 keypad encoder .
I have wrote the code and implement the cicuit but the lcd gives strange symbols //it didn't stop giving these
The code is down,
I hope someone give me a cause ....
thank you all..

/*****************************************************
This program was produced by the
CodeWizardAVR V2.03.4 Standard
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project :
Version :
Date : 10/17/2010
Author :
Company :
Comments:

Chip type : ATmega8535
Program type : Application
Clock frequency : 1.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 128
*****************************************************/

#include

// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include

// Declare your global variables here
int n=0;
int i=0;
int x;
char string [16] ;

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0xFF;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;

// LCD module initialization
lcd_init(16);

while (1)
{
// Place your code here
for(x=0;x<=16;x++)
{
switch (PORTB) {
case 0x00:
lcd_gotoxy(i,0);
lcd_putsf("A");
string[n]='A';
n++;
i++;
break;

case 0x01:
lcd_gotoxy(i,0);
lcd_putsf("B");
string[n]='B';
n++;
i++;
break;

case 0x02:
lcd_gotoxy(i,0);
lcd_putsf("C");
string[n]='C';
n++;
i++;
break;

case 0x03:
lcd_gotoxy(i,0);
lcd_putsf("D");
string[n]='D';
n++;
i++;
break;

case 0x04:
lcd_gotoxy(i,0);
lcd_putsf("E");
string[n]='E';
n++;
i++;
break;
};

};
}
}

[/code:1][code:1]

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I suggest starting a new project and only try to display "hello Me" on the LCD.
If you get that working then expand with other things like key board interfacing.

this will make your debugging alot easier as you have somthing to put debug data to....