ESP8266 Maximum upto 7 OS_Timer
Source code :
#include <Arduino.h>
extern "C" {
#include "user_interface.h"
}
os_timer_t Timer1;
os_timer_t Timer2;
os_timer_t Timer3;
os_timer_t Timer4;
os_timer_t Timer5;
os_timer_t Timer6;
os_timer_t Timer7;
void Timer_1_Callback(void *pArg)
{
Serial.println("Timer 1 Event");
}
void Timer_2_Callback(void *pArg)
{
Serial.println("Timer 2 Event");
}
void Timer_3_Callback(void *pArg)
{
Serial.println("Timer 3 Event");
}
void Timer_4_Callback(void *pArg)
{
Serial.println("Timer 4 Event");
}
void Timer_5_Callback(void *pArg)
{
Serial.println("Timer 5 Event");
}
void Timer_6_Callback(void *pArg)
{
Serial.println("Timer 6 Event");
}
void Timer_7_Callback(void *pArg)
{
Serial.println("Timer 7 Event");
}
void setup() {
Serial.begin(115200);
delay(3000);
// put your setup code here, to run once:
//=================== Create OS timer1
os_timer_setfn(&Timer1, Timer_1_Callback, NULL);
os_timer_arm(&Timer1, 1000, true);
//=================== Create OS timer2
os_timer_setfn(&Timer2, Timer_2_Callback, NULL);
os_timer_arm(&Timer2, 1000, true);
//=================== Create OS timer3
os_timer_setfn(&Timer3, Timer_3_Callback, NULL);
os_timer_arm(&Timer3, 1000, true);
//=================== Create OS timer4
os_timer_setfn(&Timer4, Timer_4_Callback, NULL);
os_timer_arm(&Timer4, 1000, true);
//=================== Create OS timer5
os_timer_setfn(&Timer5, Timer_5_Callback, NULL);
os_timer_arm(&Timer5, 1000, true);
//=================== Create OS timer6
os_timer_setfn(&Timer6, Timer_6_Callback, NULL);
os_timer_arm(&Timer6, 1000, true);
//=================== Create OS timer7
os_timer_setfn(&Timer7, Timer_7_Callback, NULL);
os_timer_arm(&Timer7, 1000, true);
}
void loop() {
// put your main code here, to run repeatedly:
}
video Link : https://youtu.be/-k0KrUYsIqw
Source code :
#include <Arduino.h>
extern "C" {
#include "user_interface.h"
}
os_timer_t Timer1;
os_timer_t Timer2;
os_timer_t Timer3;
os_timer_t Timer4;
os_timer_t Timer5;
os_timer_t Timer6;
os_timer_t Timer7;
void Timer_1_Callback(void *pArg)
{
Serial.println("Timer 1 Event");
}
void Timer_2_Callback(void *pArg)
{
Serial.println("Timer 2 Event");
}
void Timer_3_Callback(void *pArg)
{
Serial.println("Timer 3 Event");
}
void Timer_4_Callback(void *pArg)
{
Serial.println("Timer 4 Event");
}
void Timer_5_Callback(void *pArg)
{
Serial.println("Timer 5 Event");
}
void Timer_6_Callback(void *pArg)
{
Serial.println("Timer 6 Event");
}
void Timer_7_Callback(void *pArg)
{
Serial.println("Timer 7 Event");
}
void setup() {
Serial.begin(115200);
delay(3000);
// put your setup code here, to run once:
//=================== Create OS timer1
os_timer_setfn(&Timer1, Timer_1_Callback, NULL);
os_timer_arm(&Timer1, 1000, true);
//=================== Create OS timer2
os_timer_setfn(&Timer2, Timer_2_Callback, NULL);
os_timer_arm(&Timer2, 1000, true);
//=================== Create OS timer3
os_timer_setfn(&Timer3, Timer_3_Callback, NULL);
os_timer_arm(&Timer3, 1000, true);
//=================== Create OS timer4
os_timer_setfn(&Timer4, Timer_4_Callback, NULL);
os_timer_arm(&Timer4, 1000, true);
//=================== Create OS timer5
os_timer_setfn(&Timer5, Timer_5_Callback, NULL);
os_timer_arm(&Timer5, 1000, true);
//=================== Create OS timer6
os_timer_setfn(&Timer6, Timer_6_Callback, NULL);
os_timer_arm(&Timer6, 1000, true);
//=================== Create OS timer7
os_timer_setfn(&Timer7, Timer_7_Callback, NULL);
os_timer_arm(&Timer7, 1000, true);
}
void loop() {
// put your main code here, to run repeatedly:
}
video Link : https://youtu.be/-k0KrUYsIqw