Hello everyone!
First of all i need to say that i'm new in this.
So i bought a Mega 2560 and i'm working on a project that involve 2 thermocouples and i have to start a counting when thermocouple 1 hits 40 degres Celsius and stop the counting when thermocouple hits the same temperature. The counted time has to be reserved in a variable and used later in a formula. I have no ideea how to do this. I've managed to read the values of those 2 thermocouple with the following code:
When the first thermocouple (TC) hits 40, record the value of millis() in a variable. When the 2nd TC hits 40, subtract the value of the recorded millis() variable from the current value of millis().
The beginner's guide to millis() tutorial may help.
Your code does not show.
Read the how to use this forum-please read stickies to see how to post code properly.
unsigned long StartTime = 0;
unsigned long ElapsedTime = 0;
void loop()
{
if (StartTime == 0 && Temperature1() >= 40.0)
StartTime = millis();
if (ElapsedTime == 0 && Temperature2() >= 40.0)
ElapsedTime = millis() - StartTime;
// Now, if ElapsedTime != 0 it it the number of milliseconds between
// the first temperature hitting 40 and the second temperature hitting 40
}