Good Morning, I'm trying to using keypad and then read a multiple value ... in the specific cases I'd like to press '*' blink 2 times the led and then read the second one value for example one ... and then put everything inside a variable and print it on serial ... due the fact Im not able to say to the keypad for the second charachter after blink 2 times ... wait at max un second if the user I press key read the keypad read a key otherwise go on ... below the code ... is there someone that can help me ? thanks Andrea
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13,LOW);
}
void loop(){
char customKey = customKeypad.getKey();
char customKey2;
char testo[1];
if (customKey != NO_KEY)
{
if (customKey = '*')
{
int a = 1;
int cont = 3;
asled(a,cont);
customKey2 = customKeypad.getKey();
a = 1;
cont = 4;
asled(a,cont);
testo[0] = customKey;
testo[1] = customKey2;
}
Serial.println(testo);
}
}
void asled(int a,int cont)
{
for (a = 1; a < cont; a++)
{
digitalWrite(13, HIGH);
delay(150);
digitalWrite(13, LOW);
delay(150);
}
}