Trying to get a key long press whenever it is done, without using interrupt
void checkKeys(){
if (keypad.getKeys()) // check for keypad activity
{
// we won't handle multiple keypresses, just single ones, so just key index 0
const byte key = keypad.key[0].kchar;
const byte state = keypad.key[0].kstate; // IDLE, PRESSED, HOLD, RELEASED
switch (key) {
case '#': {
static unsigned long pressedTime; // static so the value is remembered like a global
if (state == PRESSED) {
pressedTime = millis();
} else if (state == RELEASED) {
if (millis() - pressedTime > LongPress) {
send();
}
}
} break;
}
}
}
void send(){
lcd.print("Values of ");
lcd.print("");
lcd.print(" sent");
delay(2000);
}
void loop(){
// put your main code here, to run repeatedly:
read_sensors();
//checkSD();
log();
checkKeys();
lcd_display();
}
it works fine when it's the only method in void loop, i.e. checkKeys() , but when other methods, read_sensors() checkSD() log() lcd_display() , it doesn't work anymore.