For my project I am using a keypad to enter a reference.
I would like to save the complete reference as a parameter but I don't know how to do it
Here is what I did for the moment
void refPDU ()
{
//reference as XXX-XXX-XXX
delay(1000);
int i = 0;
int j = 0;
int n = 0;
Serial.println("Serial number of PDU: ");
while (i != 3 && n < 11)
{
while (j != 3)
{
char customKey = customKeypad.waitForKey();
if(customKey)
{
Serial.print(customKey);
referencePDU[n] = Serial.read();
n += 1;
}
j += 1;
}
Serial.print("-");
j = 0;
i += 1;
}
Serial.println("");
Serial.println(referencePDU);
return;
}
Of course, it makes no sense to print customKey and then assign referencePDU something you read from the serial port, without checking that there is anything to read.
My goal is to enter my reference and when I reach 11 caracters ( xxx-xxx-xxx ), it saves my reference in referencePDU parameters so that I can use this parameter later
Using :
Serial.print(customKey);
referencePDU[n] = customKey;
n += 1;
I have :
Serial number of PDU:
192-538-765-
192538765
Getting closer ^^ But how could I have the - between each group of 3 numbers ?