Arduino Programming – Interval

How to write a program that fires actions with different intervals without using the delay() function. Configuration of the serial port and printing values is also explained.

I explain you how to write a program that fires actions with different intervals without using the delay() function. Configuration of the serial port and printing values is also explained.

Level: beginner with Arduino. ( Basic knowledge of programming principles like if/else and variables ).

Interval_basic.ino:

Interval_for_loop.ino:

  • Muhammad Sarfaraz

    How to use this function to run two different independent events. for example cooling and heating of air conditioner. If temperature is greater than a specified value let’s say 30C, than check the time from last stop to now, if time is greater than lets say 5 minutes than start cooling other wise wait for completion of 5 minutes.
    similarly if temperature is less than a specified low temperature lets say 5c. than before starting heating check if time from last stop to now is greater than 2 minutes or not, if yes than start heating otherwise wait for completion of 2 minutes.
    some other functions may also be called within these functions like lcd data blinking.
    The point is the interval of cooling should not effect heating interval and vice a versa. have any idea?

  • Well each interval is their own variable. So they are independent.