Trouble Connecting Phone 3x4 Matrix Keypad

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
MrSTUDofRC
 
Posts: 16
Joined: Wed Aug 19, 2015 11:04 pm

Trouble Connecting Phone 3x4 Matrix Keypad

Post by MrSTUDofRC »

Okay so I have tried every configuration imaginable and the keypad will NOT work

The keys do nothing or they don't correspond to the symbols on the buttons - etc

I tried connecting it as it said in the description - didn't work

I tried using it with the Keypad.h examples and with my program - which worked with another Keypad - but not with this one

My code turns on an LED and sends a signal depending on if the code is accepted or not
It displays asterisks and beeps for every input
Right now its configured for a 3 character code "123"

Here is my code:

Code: Select all

//import libraries
#include <Password.h>
#include <Keypad.h>
#include <LiquidCrystal.h>

#define GreenStrip 9//green LED's
#define RedStrip 10//red LED's
#define buzzerPin 11//buzzer

#define accepted 12//accepted signal to PLC
#define declined 13//declined signal to PLC

//relay values
#define RELAY_ON 1
#define RELAY_OFF 0

Password password = Password("123");  // password
int dlugosc = 3;                        // length of the password
 
LiquidCrystal lcd(22, 23, 24, 25, 26, 27);//(RS, E, D4, D5, D6, D7)

int ilosc;//number of clicks

const byte ROWS = 4; // rows
const byte COLS = 3; // cols
 
char keys[ROWS][COLS] =
{
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
 
byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {6,7,8};
 
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  
  Serial.begin(9600);//begin serial
  
  keypad.addEventListener(keypadEvent);//add keypad

  //outputs
  pinMode(GreenStrip, OUTPUT);
  pinMode(RedStrip, OUTPUT);

  pinMode(buzzerPin, OUTPUT);

  pinMode(accepted, OUTPUT);
  pinMode(declined, OUTPUT);

  //default states
  digitalWrite(GreenStrip, RELAY_OFF);
  digitalWrite(RedStrip, RELAY_OFF);

  noTone(buzzerPin);

  digitalWrite(accepted, RELAY_OFF);
  digitalWrite(declined, RELAY_OFF);

  lcd.begin(16, 1);//initialize LCD
  
  lcd.clear();
  lcd.print("   ENTER CODE   ");

}

void loop() {

  keypad.getKey();//run main method

}

 void keypadEvent(KeypadEvent eKey) {
  
  switch (keypad.getState()) {
    
    case PRESSED://if key is pressed beep
   
      for(int i = 1; i <= 1; i++ ) {

        tone(buzzerPin, HIGH);  
        delay(50);            
        noTone(buzzerPin);  
        delay(50);      
       }    
 
     Serial.print("Pressed: ");
     Serial.println(eKey);
 
     switch (eKey) {

       case '#':
       break;
 
       case '*':
       break;

       default:
       ilosc=ilosc+1;
       password.append(eKey);
   }

    //print statements
    if(ilosc == 1) {
    
      lcd.clear();
      lcd.print("*_");
    
    }
  
    if(ilosc == 2) {

      lcd.clear();
      lcd.print("**_");
    
    }
  
    if(ilosc == 3) {
  
      lcd.clear();
      lcd.print("***_");
    
    }
  
    if(ilosc == 4) {

      lcd.clear();
      lcd.print("****_");
    
    }
  
    if(ilosc == 5) {

      lcd.clear();
      lcd.print("*****_");
    
    }
  
    if(ilosc == 6) {

      lcd.clear();
      lcd.print("******_");
    
    }
  
    if(ilosc == 7) {

      lcd.clear();
      lcd.print("*******_");
    
    }
  
    if(ilosc == 8) {

      lcd.clear();
      lcd.print("********_");
    
    }

    if(ilosc == 9) {
  
      lcd.clear();
      lcd.print("*********_");
    
    }
 
    if(ilosc == 10) {

      lcd.clear();
      lcd.print("**********_");
    
    }

    if(ilosc == 11) {

      lcd.clear();
      lcd.print("***********_");
    
    }

    if(ilosc == 12) {
 
      lcd.clear();
      lcd.print("************_");
    
    }

    if(ilosc == 13) {

      lcd.clear();
      lcd.print("*************_");
    
    }

    if(ilosc == 14) {
  
      lcd.clear();
      lcd.print("**************_");
    
    }

    if(ilosc == 15) {

      lcd.clear();
      lcd.print("***************");

    }

    //if number of entered keys equas passwords length check password
    if(ilosc == dlugosc) {
  
      delay(250);
      checkPassword();
      ilosc = 0;
    
    }
  }
}
 
void checkPassword() {

  if (password.evaluate()) {//if password is correct

    digitalWrite(RedStrip, RELAY_OFF);//make sure red strip is off

    for(int i = 1; i <= 2; i++ ) {//beep and blink
   
      tone(buzzerPin, 255);  
      digitalWrite(GreenStrip, RELAY_ON);
      delay(100);   
      digitalWrite(GreenStrip, RELAY_OFF);         
      noTone(buzzerPin);  
      delay(100);   
    
    }    
    
    ilosc = 0;//reset

    //send signal to PLC
    digitalWrite(accepted, RELAY_ON);
    delay(100); 
    digitalWrite(accepted, RELAY_OFF);

    //print message
    lcd.clear();
    lcd.print("    ACCEPTED    "); 
    delay(150);
   
   } 
  
   else {//if its not correct

     digitalWrite(GreenStrip, RELAY_OFF);//make sure green strip is off

     //reset
     ilosc = 0;  
     password.reset();

     //send message to PLC
     digitalWrite(declined, RELAY_ON);
     delay(100);
     digitalWrite(declined, RELAY_OFF);  

     //turn red strip on until penalty runs and PWR shuts keypad off
     digitalWrite(RedStrip, RELAY_ON);

     //print message
     lcd.clear();
     lcd.print("     DENIED     ");
     delay(150);
    
  }
}
And here is a link to the product im referring to: https://www.adafruit.com/products/1824

Maybe its defective?

Thanks!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Trouble Connecting Phone 3x4 Matrix Keypad

Post by adafruit_support_mike »

Try dropping back to the sample code on the product page. Does that give you valid output?

User avatar
MrSTUDofRC
 
Posts: 16
Joined: Wed Aug 19, 2015 11:04 pm

Re: Trouble Connecting Phone 3x4 Matrix Keypad

Post by MrSTUDofRC »

And how would you like me to connect it? As far as column pins and row pins

User avatar
MrSTUDofRC
 
Posts: 16
Joined: Wed Aug 19, 2015 11:04 pm

Re: Trouble Connecting Phone 3x4 Matrix Keypad

Post by MrSTUDofRC »

I just need to know the pinout of the keypad - like which pins correspond to columns 1, 2, and 3 and which pins correspond to rows 1, 2 ,3 and 4 - and which pin is unused

With that information I will be able to hook it up correctly

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Trouble Connecting Phone 3x4 Matrix Keypad

Post by Franklin97355 »

As far as I can tell this is the pinout.
Attachments
2015-08-20_11h31_16.png
2015-08-20_11h31_16.png (332.58 KiB) Viewed 345 times

User avatar
MrSTUDofRC
 
Posts: 16
Joined: Wed Aug 19, 2015 11:04 pm

Re: Trouble Connecting Phone 3x4 Matrix Keypad

Post by MrSTUDofRC »

Okay THANKYOU - I just had the connections backwards - got it working:)

User avatar
swspeed
 
Posts: 1
Joined: Sat Apr 16, 2016 1:08 pm

Re: Trouble Connecting Phone 3x4 Matrix Keypad

Post by swspeed »

Is it work without external register?

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”