This is the program (not finished as you can see):
// CONSTANTS
const char STATE_DEFAULT = 'A';
// ENVIRONMENT VARIABLES
long currentTime = 0;
char state = STATE_DEFAULT;
int redInterval = 0;
int blueInterval = 0;
int greenInterval = 0;
long redStartTime = 0;
long blueStartTime = 0;
long greenStartTime = 0;
void setup()
{
Serial.begin(9600);
setColorInterval(redStartTime, redInterval);
setColorInterval(blueStartTime, blueInterval);
ssetColorInterval(greenStartTime, greenInterval);
}
void loop()
{
}
void setColorInterval(long &startTime, int &interval, int minInterval, int maxInterval)
{
if((startTime == 0) || (currentTime - startTime >= interval))
{
interval = random(minInterval, maxInterval);
startTime = currentTime;
}
}
void setColorInterval(long &startTime, int &interval)
{
setColorInterval(startTime, interval, 0, 10000);
}
When I compile this code I get a "In function 'void setup()': error: 'setColorInterval' was not declared in this scope".
Even when I move the function call from setup to loop() it still gives me the error for loop. Why am I getting this error?
This works indead, but it should work without. I have written programs in arduino before in the same way and it worked perfect. This is because the arduino build environment automatically creates prototypes for functions in the main tab of a sketch so there is no need to put a function declaration before it is called. So my question remaines.
I notice that you've defined setColorInterval() twice, with different arguments. I didn't think you could do this with 'C'-style functions. I thought it could only be done inside a C++ class.
It's possible that this double definition is confusing the preprocessor, so it doesn't output a declaration for that function. You might try changing it to one function to see if it fixes the problem.
@seeDoubleYou
If you are still having problems, post your code, again. After all the modifications, it's hard to tell what the problem is, since we can't see over your shoulder.