#include <Time.h>
#include <TimeAlarms.h>
#include<LiquidCrystal.h>
void(){
int gettime;
int pulse;
if(gettime < second() || gettime==NULL){
gettime = second();
pulse = 2;
}
lcd.clear();
lcd.print(gettime);
lcd.setCursor(0,1);
lcd.print(second());
delay(3000);
}
(assume setup is set up correctly)
the value for second() comes out just fine, but gettime for some reason keeps taking on big values like 128, 256 and 325, etc.
You create a variable with
int gettime;
and then without ever assigning it a value, you test it two lines latter.
if(gettime < second() || gettime==NULL){
With each iteration of loop the old gettime is forgotten and a new one created. You probably need to create gettime as a global variable. But that's just guessing without seeing all your code.
You can't have a function name that uses a keyword (e.g., void), which is a type specifier, not a function name. I'm assuming you meant loop(), but that's only a guess. You don't have to make gettime a global. You could also define it within the function as:
static int gettine = 0;
The advantage is that it is now encapsulated within the function, but retains its value on the next call. However, then I'm unclear on what the test against NULL is supposed to do.
what i wanted help on
I'm unclear on what the test against NULL is supposed to do.
for a declared yet uninitialized character array, each element (i believe) has \0 to designate its empty content. so i can turn this into a boolean such as..
if(array[5]=='\0'){
something...
}
i wanted to know what the integer equivalent for '\0' would be. i thought it was NULL.
... but gettime is an int, it is not "a declared but uninitialized character array".
Your theory makes no sense.
The value of a null pointer, might, or might not, happen to be equal to zero. It may be implementation dependent.
Testing the value of an int, to be null, is pointless.
This looks like a bad habit you have got from java, but even in that context it is wrong.
You need to distinguish between the value of a pointer being null, and the contents of the memory locations that the pointer points to ( or not ), being uninitialized.
if(gettime < second() || gettime==NULL){
gettime = second();
Is gettime a function, a variable or what?
I withdraw that question. But testing an int for equality to NULL doesn't make any sense. You will probably find NULL is equivalent to zero, so why not test for zero if that is what you want?