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 {;  }      
if ( digitalRead (inp6)==0){led6.on();  } else {;Blynk.notify("PLC Stop !!!");}       
if ( digitalRead (inp12)==0){led12.on();  } else {;}   
if ( digitalRead (inp18)==0){led18.on();Blynk.notify("Alarm"); } else {;}
if ( digitalRead (inp27)==1){;Blynk.notify("Test"); }                           
if ( digitalRead (inp29)==1){led29.on();} else {;}                                   
if ( digitalRead (inp37)==1){led37.on();} else {;}                                   
if ( digitalRead (inp45)==1){led29.on();} else {;}                                  
if ( digitalRead (inp47)==1){led47.on();} else {;}  

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; commands in your function, say after ever two or thee digital ‘if’ statements.


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.


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 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.


the problem was the network card, certainly defective. I mounted a w5100 and it is working fine without 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.