Pages: [1]   Go Down
Author Topic: keypad question?  (Read 441 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello all,
i would like to interface a 3x4 keypad with my arduino without using the 74c922 encoder, so what is the code that i could use for this project ?
what will i connect rows as input colums ??????
any one know something ?
« Last Edit: February 28, 2009, 05:51:22 pm by nart_schinakow » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

u may use 7 pins to scan the key . 4 pins for output and 3pins for input .the input conet to GND wiht a resistance to Pull Low  level .then as the key pressed one of the input should be draw high and u can read it. at one time just keep one ouput HIGH and the other pins ouput LOW ,and loop the 4 pins. when the key been pressed u can get the the specific weave of input and output pins.
« Last Edit: March 01, 2009, 11:00:41 pm by sosox » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And don't forget to use some form of software button filtering to eliminate contact bouncing as some matrix keyboards can be pretty flaky.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you all for your replies, please can anyone just put the schematic of the keypad and the resistors ?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just a 4*4 keypad code .
Quote
void setup()  {
                 Serial.begin(9600);
                 for(i=0;i<4;i++)     pinMode((KeyOPin + i), OUTPUT);    
                 for (i=0;i<4;i++)    pinMode(( KeyIPin + i), INPUT);  
           }    
void loop()
          {
             reg = 1;
             for (i=0;i<4;i++)
            {
                  for (n=0;n<4;n++)
                       {
                         if((reg>>n)&1)        digitalWrite(KeyOPin+n , HIGH);
                         else                        digitalWrite(KeyOPin+n , LOW);
                       }  
                  for (n=0;n<4;n++)
                       {
                          if(digitalRead(KeyIPin + n))
                               {    
                                key = key | (1<<(4+n));  
                                key = key|reg ;
                               }                    
                        }
                  reg = reg << 1;
               }

              if (key & 0xf0)
             {
                   if (key!=oldkey)   {   press = 1;  oldkey = key ; }
             }
             else       oldkey = 0;
  
              if (press)
            {
                 Serial.print(key,BYTE);
            }
             press = 0;
             key = 0;
          }

Logged

Pages: [1]   Go Up
Jump to: