I'm pretty new to programming, though I have done some c# (a small amount).
Sorry for the class/method/function confusion, I didn't know what to call it. Anyway you'll be able to see what I mean from my code.
I'm building a aquarium controller for my marine fish tank which I want to be able to control lighting, temp, pumps etc etc.
I've got the real time clock and temp monitor working, but I'm having trouble.
Anyway I have this piece of code below:
void lightmode(){
if (printDate.hour >= 9 && printDate.hour <= 18)
{
Serial.println("Lights are enabled");
}
which I want to call this class(?): void printDate(){ .
But i'm getting this error: "request for member 'hour' in 'printDate', which is of non-class type 'void ()()'"
Do I have to set them as public or something like I would in c#? I tried and failed miserably.
I uploaded the .ino file as well if that helps.
You want to do what??? You want to call this 'Function'.
(1) printDate() is a function, you can't access local variables from one function inside another.
(2) what are you actually trying to do?
I presume what you want to do is something like follows:
(1) have some function which gets the current date and time from your controller
(2) do something which uses the current date/time
So you need some way of storing all the second, minute, hour, etc. The easiest way would be to make these global variables rather than local ones. That way all of your functions will have access to it.
Yeah I would have called it a function/method but when I was searching for help with this before posting I found someone with a similar problem who called it classes. But I guess he was talking about something entirely different.
Thanks Tom, I figured it out, i declared the hour as a global at the top of the code, changed the hour to not be a new integer, and added the function inside the loop. All working as expected.