Hi,
I've been struggling to find an answer to a relative simple question.
I want to write a program to monitor my greenhouse stats.
There will be 25 inputs and 8 outputs.
I will have the need to read my temperature sensors every 10 seconds. Obviously I won't be able to use the delay-function.
I want to have the void ReadTemp() triggered when an internal timer has reached 10 seconds.
After the temperatures have been read the program needs to resume.
There are multiple examples online about switching multiple LED's but nothing about calling a function by timer interrupt.
Can somebody point me in the right direction please? By the way, I am using a Mega 2560 board.
Cheers,
There are multiple examples online about switching multiple LED's
In the examples that you have found how and where are the LEDs switched ? It will either be in a function or in online code. How about you post an example of what you have found.
LRAT:
Hi,
I've been struggling to find an answer to a relative simple question.
I want to write a program to monitor my greenhouse stats.
There will be 25 inputs and 8 outputs.
I will have the need to read my temperature sensors every 10 seconds. Obviously I won't be able to use the delay-function.
I want to have the void ReadTemp() triggered when an internal timer has reached 10 seconds.
After the temperatures have been read the program needs to resume.
Timescale necessitating interrupts, 10^-3 to 10^-6 seconds. Timescale you are needing 10^1 second...
There's no need for interrupts, just the standard do-something-regularly test in loop()
unsigned long last_time = 0L ;
#DEFINE PERIOD 10000 // ms between readings
void loop ()
{
if (millis () - last_time > PERIOD) // standard check for event due
{
last_time += PERIOD ; // setup for next time
do_my_stuff () ;
}
// other loop stuff
}
BTW none of the internal timers times for more than 2ms in the default config, they are used
for PWM and for driving the ISR that is used by millis(), micros() and delay().