this is what I tried but return wont return array . how do I do it ?
the //*** are what I tried
I am inserting this into a larger code and want to make a function so the main code is not so clumsy. I was also going to put it in its own tab .
const byte TIME = 5;
unsigned long previousMillis = 0;
int Timer=0 ;
int Printed=0;
int TIME1[] = {LOW,LOW,LOW,LOW,LOW};
int Case1=500;
int Case2=20000;
int Case3=30000;
long Case4=40000;
long Case5=50000;
#define D4 3
unsigned long previousMillisCase1;
unsigned long previousMillisCase2;
unsigned long previousMillisCase3 ;
unsigned long previousMillisCase4;
unsigned long previousMillisCase5;
void setup()
{
Serial.begin(115200);
}
void loop(){
//*******
[color=red]int TimeState ();[/color]
//********
if ((TIME1[0]==1)&&Printed==0) //suppress i=0 timer only show 1-4 i=0 is for status timer
{
int i=0;
for(int i = 1; i < 5; i++)
{
Serial.print(TIME1[i]);
};
Serial.println();
Printed=1;
}
else
{
if (TIME1[0]==0)
Printed=0;
};
}
//*****
[color=red]int TimeState ()
{
unsigned long currentMillis=millis();
if ((unsigned long)(currentMillis - previousMillisCase1 >=Case1))
{
TIME1[0]=!TIME1[0];
previousMillisCase1 = currentMillis;
};
if ((unsigned long)(currentMillis - previousMillisCase2 >=Case2))
{
TIME1[1]=!TIME1[1];
previousMillisCase2 = currentMillis;
};
if ((unsigned long)(currentMillis - previousMillisCase3 >=Case3))
{
TIME1[2]=!TIME1[2];
previousMillisCase3 = currentMillis;
};
if ((unsigned long)(currentMillis - previousMillisCase4 >=Case4))
{
TIME1[3]=!TIME1[3];
previousMillisCase4 = currentMillis;
};
if ((unsigned long)(currentMillis - previousMillisCase5 >=Case5))
{
TIME1[4]=!TIME1[4];
previousMillisCase5 = currentMillis;
};
return TIME1;
};
[/color]//****