user25877: 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 <SimpleTimer.h>

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?

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

25877: <p>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.</p>

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

<p><strong>Code</strong></p>

<pre><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() {
}
</code></pre>

<p>The problem is that the LED stays just on (<em>digitalWrite(26, HIGH);</em>) instead of going to the <em>switchOff</em> function and turning off (<em>digitalWrite(26, LOW);</em>). 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?</p>
 2881: <p>You have to call <code>timer.run()</code> inside loop function.</p>

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