Perform function after a period of time I am working on a project that I am supplying with voltage an LED through a digital pin (26) and I want the LED to be switched off after 4 seconds.

I am using Arduino Mega2560 and I am programming it using Arduino's IDE version 1.6.10. I have installed the SimpleTimer library .zip method but it does not seem to function. 

Code

#include &lt;SimpleTimer.h&gt;

SimpleTimer timer;

void setup() {
pinMode(26, OUTPUT);
digitalWrite(26, HIGH);


timerId = timer.setTimeout(4000, switchOff);
}

void switchOff() {
  digitalWrite(26, LOW);
}

void loop() {
}


The problem is that the LED stays just on (digitalWrite(26, HIGH);) instead of going to the switchOff function and turning off (digitalWrite(26, LOW);). I have also tried using Timer1 and Timer libraries but they also do not work. Can someone who has made any of the libraries work, provide me with some guidance?
You have to call timer.run() inside loop function.

The SimpleTimer library is more like a scheduler. You call at every so often, and it checks if there is any event that has expired.