Print 8 characters
Posted: Tue Jan 26, 2021 2:36 pm
Hi I'm new here. I'm writting a code for an Escape Room puzzle. It's about esp-now where one controller is connected to a 3x4 keyboard, and the second one is for controlling the game (it shows what people write from the keyobard). Now, I've got a code that prints every character one by one, and I'd like to have a code that prints every 8 characters together. What should I do? I'm lost.
Here is the code of the keyobard controller, which first part is what I need, cause it's printing only one by one character.
Second part is checking if the code is right with the password.
Third is to reset the code with a " * " character.
Here is the code of the keyobard controller, which first part is what I need, cause it's printing only one by one character.
Second part is checking if the code is right with the password.
Third is to reset the code with a " * " character.
Code: Select all
void sendData() {
char customKey = customKeypad.getKey();
if (customKey == '*')reset();
else if (customKey)
{
dane[x]= customKey;
x++;
Serial.println(customKey);
uint8_t bs[sizeof(customKey)];
memcpy(bs, &customKey, sizeof(customKey));
esp_now_send(mac, bs, sizeof(customKey));
}
if ( dane[0]== password[0] &&
dane[1]== password[1] &&
dane[2] == password[2] &&
dane[3] == password[3] &&
dane[4] == password[4] &&
dane[5] == password[5] &&
dane[6] == password[6] &&
dane[7] == password[7] )
{
uint8_t bs[sizeof(work)];
memcpy(bs, &work, sizeof(work));
esp_now_send(mac, bs, sizeof(work));
Serial.println(work.text);;
delay(5000);
reset();
}}
void reset() {
for(int i=0; i<8; i++)
{
dane[i]=0;
x=0;
uint8_t bs[sizeof(res)];
memcpy(bs, &res, sizeof(res));
esp_now_send(mac, bs, sizeof(res));
}Serial.println(res.text);
}