I need some help wrapping my head around how to do this. I am imagining some type of for loop but am unsure on how to implement it. Any help would be appreciated.
Example:
I would like to take multiple dewpoint readings to determine if the dewpoint is dropping over time, say 5 minutes.
Here is my code for determining dewpoint based off temperature and humidity readings.
It's pointless to say that the function takes a double when you don't assign a name to the argument. That means that you can't reference the value in the function, so taking a double is pointless.
Why do you need to get the dew point more often than every 5 minutes? Even if you do, why not simply record the value every 5 minutes. The values every 5 minutes are either the same, increasing or decreasing.
Paul-Im obviously very new and dont quite understand what goes inside the (). Ive searched around but cant seem to find much info, likely because I dont know the correct search terms. Can you point me somewhere that I could read to better understand?
Thanks a lot Rob! I really appreciate you doing that. To make sure I understand I should always put double/float/int before a variable even if it was declared in the beginning of the sketch. I realize you didn't see the beginning but I do have:
double h =0
double dt=0 etc...
I am sure that I wasn't exactly clear on what I am trying to accomplish. I would like to monitor the dewpoint over a 5 minute period to determine if the dewpoint is changing. This would be to ensure that there isn't a false decision made based on a snapshot reading.
timmyjane:
Thanks a lot Rob! I really appreciate you doing that. To make sure I understand I should always put double/float/int before a variable even if it was declared in the beginning of the sketch. I realize you didn't see the beginning but I do have:
double h =0
double dt=0 etc...
only the first time you need to tell the compiler what type it is. There after it knows. Furthermore there exists something called scope which indicates on what level the variable is known. You can have a global variable that is known everywhere, or a local variable with the same name that is only known inside a function or a compound block. Within a scope names must be unique. A scope is defined by a { } pair so an if statement or a for loop have their own scope;
here some code that shows effect of scope on different levels.
int a = 10;
void setup()
{
Serial.begin(9600);
Serial.println(a);
int b = func(a);
for (int a = 0; a <3; a++)
{
Serial.println(a);
}
if (b > a)
{
int a = 3;
Serial.println(a);
}
else
{
int a = 4;
Serial.println(a);
}
}
int func(int x)
{
int a = 5;
Serial.println(a);
Serial.println(x);
return a;
}
void loop(){}
That's good advice Paul and exactly what I have been doing the last few hours, referencing my library. Sometime it is difficult to find what you need on the net because you only get snippets of information.