10-05-2022, 01:11 PM
such as:
if(pcf8574_I1.digitalRead(P0) == LOW) //key1 pressed
{
delay(20); //anti-interference
if(pcf8574_I1.digitalRead(P0) == LOW) //key1 pressed again
{
pcf8574_R1.digitalWrite(P0,!pcf8574_R1.digitalRead(P0)); // toggle relay1 state
while(pcf8574_I1.digitalRead(P0) == LOW); //wait remove hand
if (pcf8574_R1.digitalRead(P0) == LOW) relay1state= "on"; else relay1state= "off";
}
}
//-------------------------------------------------------------------------------------------------------
you just change every key funtion's "delay(20);" replace 20 with other number will have different time.
if(pcf8574_I1.digitalRead(P0) == LOW) //key1 pressed
{
delay(20); //anti-interference
if(pcf8574_I1.digitalRead(P0) == LOW) //key1 pressed again
{
pcf8574_R1.digitalWrite(P0,!pcf8574_R1.digitalRead(P0)); // toggle relay1 state
while(pcf8574_I1.digitalRead(P0) == LOW); //wait remove hand
if (pcf8574_R1.digitalRead(P0) == LOW) relay1state= "on"; else relay1state= "off";
}
}
//-------------------------------------------------------------------------------------------------------
you just change every key funtion's "delay(20);" replace 20 with other number will have different time.