hi, sir , the enable pin need pulse rising edge to enable the setting, so , you need to first digitalwrite low to the enable , and then digitalwrite HIGH to this pin.
for example:
void turnSwitchOnOff(byte sw)
{
digitalWrite(sw,HIGH); // set the relay state.
/// gives a rising edge to enable pin
digitalWrite(enablePin,LOW);
delay(100);
digitalWrite(enablePin,HIGH);
////
delay(1000);
}
I had to increase a little bit the delay between the two digitalWrite to make it more reliable, but now it works like a charm. Thanks. Here the code for reference
void turnSwitchOnOff(byte sw)
{
digitalWrite(sw,HIGH); // set the relay state.
// Gives a rising edge to enable pin
digitalWrite(enablePin,LOW);
delay(200);
digitalWrite(enablePin,HIGH);
//
delay(1000);
}
The new code worked correctly for a couple of days, but now it started to have the same original behaviour: sometimes signal are ignored, sometimes doubled.