I have a simple code to run on an Arduino Mega controlling 17 relays. Originally i wrote it where I had each relay listed for high and low and a delay in between. I figured their was a better way so I started to play around with int. The problem Im running into is ive declared my int in "STEPS" and then am trying to reset it to 1 in "GATE". This seems to upsets the Arduino overlords. Im sure their is a better way hope someone can help me out.
#define STEP(s) 1-17... //this is just to truncate my code I have each relay defined.
int n = 1;
long STEP(n);
long RandNumber;
void setup()
{
pinMode(STEP1, OUTPUT... //I have 1-17 defined as output truncated for the post
}
void loop()
{
STEPS:
digitalWrite(STEP,LOW); // Turns ON Relay(n)
delay(1000); // Wait 1 seconds
digitalWrite(STEP,HIGH); // Turns OFF Relay(n)
int n=n+1 ; // increase n by 1
if (n >= 17) {goto GATE;} // end loop if n=17
else goto STEPS; // go to next point
GATE:
digitalWrite(RELAY17,LOW); // Turn ON Relay 17
delay(10000); // Wait 10 seconds
digitalWrite(RELAY17,HIGH); // Turn OFF Relay 17
int n=1 ; // Reset (n) to 1
RandNumber = random(5000,20000); // establish random range
delay(RandNumber); // delay for random seconds
goto STEPS;} // go to starting point
}