How many functions in a timer?

are these features correct for a single timer?

timer.setInterval(800L, buttonLedWidget);
.......

void buttonLedWidget(){

if ( digitalRead (inp5)==0){led5.on();  } else {led5.off();  }      
if ( digitalRead (inp6)==0){led6.on();  } else {led6.off();Blynk.notify("PLC Stop !!!");}       
if ( digitalRead (inp12)==0){led12.on();  } else {led12.off();}   
if ( digitalRead (inp18)==0){led18.on();Blynk.notify("Alarm"); } else {led18.off();}
if ( digitalRead (inp27)==1){;Blynk.notify("Test"); }                           
if ( digitalRead (inp29)==1){led29.on();} else {led29.off();}                                   
if ( digitalRead (inp37)==1){led37.on();} else {led37.off();}                                   
if ( digitalRead (inp45)==1){led29.on();} else {led45.off();}                                  
if ( digitalRead (inp47)==1){led47.on();} else {led47.off();}  
}                                

I have problems of disconnection, there are too many functions I have to set timers with different times for each single reading?

If you increase the time from 800 to say, 1800 does the problem go away?
If so, I suspect the Blynk calls may be too frequent.

I’d capture the time at the beginning and end of the function …

void buttonLedWidget(){
   long int start_time = millis();
   // ...
   Serial.println(millis() - start_time);
}

Put a few Blynk.run(); commands in your function, say after ever two or thee digital ‘if’ statements.

Pete.

time result is 14

You have nothing preventing these notifications from attempting to process each timer iteration (if the pin is the needed value). But there is a 5 second limit between consecutive calls.

image

That’s 14 ms. I’d probably look elsewhere for your disconnection issue.

messages are sent very rarely. I will soon put a time limitation

I have tried every cause but I have the same result.
I also increased the timer time to 1000L

If you’ve tried adding extra Blynk.run commands then perhaps you should post your full code and a few more details about exactly what symptoms you’re seeing and what you get in your serial monitor.

Pete.

the problem was the network card, certainly defective. I mounted a w5100 and it is working fine without Blink.run in the middle of if.

The process time has dropped to 6ms

1 Like

I spent soooo much time messing around with various Ethernet shields and libraries for the Arduino before I finally saw the light.

Pete.