QWERTY KEYPAD SAMPLE PROGRAM FOR RABBIT6700

hiiiii

i need the sample program for qwerty keypad sample program (3*10).can any one help me…

@satis,

The keypad consists of several switches that if you press the 1 button it will have 2 ports of microcontroller connected.

Example, we have a 4x4 keypad connected with 8 ports of the microcontroller. We can assume 4 ports as input(columns) and 4 ports as output(rows).

We provide logic 0 to the first input (first column), then we read the first output (first row), doing readings up to four rows. From there, it will see the difference when the button is pressed or not.

And do giving input in the second column, then repeat a reading each rows(row 1 until row 4) to obtain the output. Do repeat until last columns.

Example 4x4

1 2 3 A
4 5 6 B
7 8 9 C
D 0 E F

unsigned char getKey(){
   unsigned char col, writeCol, readRow;

   for(col=4; col>0; col--){
      writeCol = ~(unsigned char)(1<>4)&0x0F;
       switch(readRow ){
          case 7:
            if(col==4)
                return 1;
            else if(col==5)
                return 2;
            else if(col==6)
                return 3;
            else if(col==7)
                return 0x0A;
             break;

          case 0x0B:
            if(col==4)
                return 4;
            else if(col==5)
                return 5;
            else if(col==6)
                return 6;
            else if(col==7)
                return 0x0B;
            break;

          case 0x0D:
            if(col==4)
                return 7;
            else if(col==5)
                return 8;
            else if(col==6)
                return 9;
            else if(col==7)
                return 0x0C;
            break;

          case 0x0E:
            if(col==4)
                return 0x0D;
            else if(col==5)
                return 0;
            else if(col==6)
                return 0x0E;
            else if(col==7)
                return 0x0F;
      }
   }
}

void main(){
   brdInit();

   // set  4 bits lsb as inputs and 4 bits msb as outputs 
   WrPortI(PEDR, &PEDRShadow, 0xF0);

   for(;;)
      printf("%02X ", getKey());
}