
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);
}