user38558: Following is the code I found in Arduino example files. It compiled fine on Arduino UNO. But there was an error when I tried to compile it for nodeMCU 1.0(ESP 12E Module).
#include <TimerOne.h>
void setup() {
  pinMode(13,OUTPUT);
  Timer1.initialize(5000000);//5 sec
  Timer1.attachInterrupt(timerIsr);
}
void loop() {}
void timerIsr(){
  digitalWrite(13,!digitalRead(13));
}

Following was the error message. I had this kind of error previously on OneWire.h and I solved it by replacing the OneWire.h library with another OneWire.h library that was made especially for nodeMCU.
Error msg:
Arduino: 1.8.3 (Windows 8.1), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from D:\iox Prime\TEC project\code\building modules\timerIsrDemo\timerIsrDemo.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\TimerOne/TimerOne.h:39:20: fatal error: avr/io.h: No such file or directory

 #include <avr/io.h>

                    ^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I searched the library everywhere in the internet to solve this error but end up with no success. I wish somebody modifies the existing library for me. Thank you for the help.

user4143: The TimerOne library is specifically for Timer 1 on the AVR microcontrollers1. No other microcontroller has the exact same timer structure, so the library cannot be used with them.
You need a library that works with the timers the ESP8266 has, or you need to manually manipulate the timer registers, for which you will need to consult and understand the datasheet.

1: It also appears to have #defines in it for ARM (Teensy 3.x) chips.

user38558: I have found a solution. There is a library called Ticker.h
I found this on github: https://github.com/esp8266/Arduino/tree/master/libraries/Ticker
Following is my demo code:
#include <Ticker.h>
Ticker ticker;
void setup() {
  pinMode(D7,OUTPUT);
  ticker.attach(1,isrFunc);//tickerObj.attach(timeInSecs,isrFunction)
}

void loop() {}
void isrFunc(){
  digitalWrite(D7,!digitalRead(D7));
}

For me, this code worked seamlessly on nodeMCU. Thank you.

38558: <p>Following is the code I found in Arduino example files. It compiled fine on Arduino UNO. But there was an error when I tried to compile it for nodeMCU 1.0(ESP 12E Module).</p>

<pre><code>#include &lt;TimerOne.h&gt;
void setup() {
  pinMode(13,OUTPUT);
  Timer1.initialize(5000000);//5 sec
  Timer1.attachInterrupt(timerIsr);
}
void loop() {}
void timerIsr(){
  digitalWrite(13,!digitalRead(13));
}
</code></pre>

<p>Following was the error message. I had this kind of error previously on OneWire.h and I solved it by replacing the OneWire.h library with another OneWire.h library that was made especially for nodeMCU.</p>

<p>Error msg:</p>

<pre><code>Arduino: 1.8.3 (Windows 8.1), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from D:\iox Prime\TEC project\code\building modules\timerIsrDemo\timerIsrDemo.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\TimerOne/TimerOne.h:39:20: fatal error: avr/io.h: No such file or directory

 #include &lt;avr/io.h&gt;

                    ^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -&gt; Preferences.
</code></pre>

<p>I searched the library everywhere in the internet to solve this error but end up with no success. I wish somebody modifies the existing library for me. Thank you for the help.</p>
 4143: <p>The TimerOne library is specifically for Timer 1 on the AVR microcontrollers<sup>1</sup>. No other microcontroller has the exact same timer structure, so the library cannot be used with them.</p>

<p>You need a library that works with the timers the ESP8266 has, or you need to manually manipulate the timer registers, for which you will need to consult and understand the datasheet.</p>

<hr>

<p><sup>1: It also appears to have #defines in it for ARM (Teensy 3.x) chips.</sup></p>
 38558: <p>I have found a solution. There is a library called Ticker.h
I found this on github: <a href="https://github.com/esp8266/Arduino/tree/master/libraries/Ticker" rel="nofollow noreferrer">https://github.com/esp8266/Arduino/tree/master/libraries/Ticker</a></p>

<p>Following is my demo code:</p>

<pre><code>#include &lt;Ticker.h&gt;
Ticker ticker;
void setup() {
  pinMode(D7,OUTPUT);
  ticker.attach(1,isrFunc);//tickerObj.attach(timeInSecs,isrFunction)
}

void loop() {}
void isrFunc(){
  digitalWrite(D7,!digitalRead(D7));
}
</code></pre>

<p>For me, this code worked seamlessly on nodeMCU. Thank you.</p>
