arduino timer without delay() function

preview_player
Показать описание
#arduino #nodelay #delay() #multitasking #timers
you can make individual 4 timers without using delay function. so no more lag your while loop. timer interval can adjust in millisecond
pls repalce (greaterthanSymbol) with real symbol. because this you tube not allow greaterthanSymbol in description

#define timer1_time_out_in_milliSeconds 1000
#define timer2_time_out_in_milliSeconds 2000
#define timer3_time_out_in_milliSeconds 5000
#define timer4_time_out_in_milliSeconds 10000
uint16_t mil1, mil2, mil3, mil4, mil5;
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
if (millis() - mil1 (greaterthanSymbol) timer1_time_out_in_milliSeconds) {
mil1 = millis();
// put ur 1 seconds routing here
}
if (millis() - mil2 (greaterthanSymbol) timer2_time_out_in_milliSeconds) {
mil2 = millis();
// put ur 2 seconds routing here
}
if (millis() - mil3 (greaterthanSymbol) timer3_time_out_in_milliSeconds) {
mil3 = millis();
// put ur 5 seconds routing here
}
if (millis() - mil4 (greaterthanSymbol) timer4_time_out_in_milliSeconds) {
mil4 = millis();
// put ur 10 seconds routing here
}
}
Рекомендации по теме