Sign In

Comment My Understanding

opel manfred manfred.opel@student.uni-tuebingen.de Germany

Hardware: Arm Freedom Software: Gcc Compiler Keil

could you give comment to the following lines and could you give Code for 4x4 Matrix
I can give no Money for this Service.

Images

Program


4x3 Matrix keypad

72    ******************************************************************************/
73
74    #include <avr/io.h>
75    #include <util/delay.h>
76
77    #include "lcd.h"
78    #include "myutils.h"
79
80    #define KEYPAD A  //KEYPAD IS ATTACHED ON PORTA
81
82    //Don't Touch the lines below
83    //*******************************
84    #define KEYPAD_PORT PORT(KEYPAD)
85    #define KEYPAD_DDR   DDR(KEYPAD)
86    #define KEYPAD_PIN   PIN(KEYPAD)
87    //*******************************
88
89
90    /*******************************************
91
92    Function return the keycode of keypressed
93    on the Keypad. Keys are numbered as follows
94
95    [00] [01] [02]
96    [03] [04] [05]
97    [06] [07] [08]
98    [09] [10] [11]
99
100   Arguments:
101      None
102
103   Return:
104      Any number between 0-11 depending on
105      keypressed.
106
107      255 (hex 0xFF) if NO keypressed.
108
109   Precondition:
110      None. Can be called without any setup.
111
112   *******************************************/
113   uint8_t GetKeyPressed()
114   {
115      uint8_t r,c;
116
117      KEYPAD_PORT|= 0X0F;
118
119      for(c=0;c<3;c++)
120      {
121         KEYPAD_DDR&=~(0X7F);
122
123         KEYPAD_DDR|=(0X40>>c);
124         for(r=0;r<4;r++)
125         {
126            if(!(KEYPAD_PIN & (0X08>>r)))
127            {
128               return (r*3+c);
129            }
130         }
131      }
132
133      return 0XFF;//Indicate No key pressed
134   }
135
136
137   void main()
138   {
139      //Wait for LCD To Start
140      _delay_loop_2(0);
141
142      //Now initialize the module
143      LCDInit(LS_NONE);
144
145      uint8_t key;
146
147      while(1)
148      {
149         key=GetKeyPressed(); //Get the keycode of pressed key
150
151         LCDWriteIntXY(0,0,key,3);  //Print it at location 0,0 on LCD.
152      }
153
154   }

Post a reply to opel manfred

Think you can help opel manfred ? Then post your thoughts that might help opel manfred. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.