Loading...
Pages: [1]   Go Down
Author Topic: Multiples Input From Keypad (dont know !!!!)  (Read 108 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-mad
Hi i new with arduino, i like basic stamp from parallax, but now is to limited.
i have a problem with multiples input from a key pad, works the first input, but in the next
don do anything, here my code :

I really need some help with this

#include <Keypad.h>
#include <SoftwareSerial.h>

const byte rows = 4;
const byte cols = 4;

int count_grupo_a = 0;
int count_grupo_b = 0;
int count_grupo_c = 0;
int count_grupo_d = 0;

char keys[rows][cols] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[rows] = {2, 3, 4, 5};
byte colPins[cols] = {6, 7, 8, 9};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );

void setup()
{

  Serial.begin(9600);
  delay(500);
  //Keypad.addEventListener(keypadEvent);  // Add an event listener.
  //keypad.setHoldTime(500);               // Default is 1000mS
  //keypad.setDebounceTime(250);           // Default is 50mS
  clearLCD();
  selectLineOne();
  Serial.print(" Score Dominoes ");
  selectLineTwo();
  Serial.print("Group:");

}

void loop()
{
  char key = keypad.getKey(); -------> Work
 
  if (key != NO_KEY){
    if (key == 'A') {
      clearLCD();
      group_a();
      }
    }
   
  }


void group_a()
{
          Serial.println("GRUPO A");
          selectLineTwo();
          Serial.println("Valor :");
          int valor_a = keypad.getKeys(); ---------> nothing
          if (valor_a != NO_KEY){
          count_grupo_a = valor_a + count_grupo_a;
          Serial.println(count_grupo_a);
          delay(2000);
          setup();
        }
 
}

void selectLineOne(){  //puts the cursor at line 0 char 0.
  Serial.write(0xFE);   //command flag
  Serial.write(128);    //position
  delay(10);
}
void selectLineTwo(){  //puts the cursor at line 0 char 0.
  Serial.write(0xFE);   //command flag
  Serial.write(192);    //position
  delay(10);
}
void goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
  if (position<16){
    Serial.write(0xFE);   //command flag
    Serial.write((position+128));    //position
  }
  else if (position<32){
    Serial.write(0xFE);   //command flag
    Serial.write((position+48+128));    //position
  }
  else {
    goTo(0);
  }
  delay(10);
}

void clearLCD(){
  Serial.write(0xFE);   //command flag
  Serial.write(0x01);   //clear command.
  delay(10);
}
void serCommand(){   //a general function to call the command flag for issuing all other commands
  Serial.write(0xFE);
}
Logged

UK
Offline Offline
Edison Member
*
Karma: 42
Posts: 2200
What a host of balls she had seen: gaity, the brass buttons...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please edit your post to place your code between code tags.

If you'd read the stickies at the top of the forum you'd know to do that already.
Logged


Queens, New York
Offline Offline
Edison Member
*
Karma: 28
Posts: 1563
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This should have everything you need. http://arduino.cc/forum/index.php/topic,140459.0.html
Logged

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

California
Offline Offline
God Member
*****
Karma: 13
Posts: 632
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Serial.begin(9600);
  delay(500);
  //Keypad.addEventListener(keypadEvent);  // Add an event listener.
  //keypad.setHoldTime(500);               // Default is 1000mS
  //keypad.setDebounceTime(250);           // Default is 50mS
  clearLCD();
  selectLineOne();
  Serial.print(" Score Dominoes ");
  selectLineTwo();
  Serial.print("Group:");

Any reason you commented out the "Debounce" routine.  The problem you are describing is a "bounce" issue.
Logged


Pages: [1]   Go Up
Print
 
Jump to: