Hello dear Arduinoids,
I hope one of you will be kind enough to help me out here as I'm pulling my hair out with this!
I have written a sketch to control four RGB LEDs with a Arduino Mega via FETs.
The code basically consists of a number of different colour sequences written into Functions declared with "void".
The start of the sketch just calls the different Functions in the order they are needed.
Everything works just fine so long as my list of "calls" doesn't exceed around nine or so. If I make the list any longer, the first colour sequence will run but very, very, VERY slowly. If I "rem" out a few of the calls (doesn'y matter which) then it runs all fine again. There is nothing special going on in the functions - just setting pins high and low -no nesting or whatever. Is there a limit to how many funtions can be called?
I would really appreciate any help and I can post the whole sketch if necessary.
Thanks!!!
Here is a snippet of the code...
// Calling Functions here...
s1();s2(); // r
s3();s4(); // g
s5();s6(); // b
s7();s8(); // v
s9();s10(); //c
s11();s12(); //y
ws1();ws2(); //white
s13();s14(); // calling functions
s13();s14(); // r
s15();s16(); // g
s17();s18(); // b
s19();s20(); // v
s21();s22(); //c
s23();s24(); //y
ws3();ws4(); //white
// xxxxxxxxxxxxxxxxxxx Red Inc xxxxxxxxxxxxxxx
void s1() { //declare function
// turn the LEDs on
digitalWrite(2, HIGH);
delay(d3);
digitalWrite(5, HIGH);
delay(d3);
digitalWrite(8, HIGH);
delay(d3);
digitalWrite(11, HIGH); // leds on red
delay(d3);
// turn the LEDs off
digitalWrite(2, LOW);
delay(d3);
digitalWrite(5, LOW);
delay(d3);
digitalWrite(8, LOW);
delay(d3);
digitalWrite(11, LOW);; // turn the LEDs off
delay(d3);
}
void s2() { // Declare function
// turn the LEDs on reverse
digitalWrite(11, HIGH);
delay(d3);
digitalWrite(8, HIGH);
delay(d3);
digitalWrite(5, HIGH);
delay(d3);
digitalWrite(2, HIGH); // leds on red
delay(d3);
// turn the LEDs off reverse
digitalWrite(11, LOW);
delay(d3);
digitalWrite(8, LOW);
delay(d3);
digitalWrite(5, LOW);
delay(d3);
digitalWrite(2, LOW); // turn the LEDs off
delay(d3);
}
// xxxxxxxxxxxxxxxxxxx Green Inc xxxxxxxxxxxxxxx
void s3() { //declare function
// turn the LEDs on
digitalWrite(3, HIGH);
delay(d3);
digitalWrite(6, HIGH);
delay(d3);
digitalWrite(9, HIGH);
delay(d3);
digitalWrite(12, HIGH); // leds on red
delay(d3);
// turn the LEDs off
digitalWrite(3, LOW);
delay(d3);
digitalWrite(6, LOW);
delay(d3);
digitalWrite(9, LOW);
delay(d3);
digitalWrite(12, LOW); // turn the LEDs off
delay(d3);
}
//xxxxxxxxx Green Dec xxxxxxxxxxxxxx
void s4(){ // turn the LEDs on reverse
digitalWrite(12, HIGH);
delay(d3);
digitalWrite(9, HIGH);
delay(d3);
digitalWrite(6, HIGH);
delay(d3);
digitalWrite(3, HIGH); // leds on red
delay(d3);
// turn the LEDs off reverse
digitalWrite(12, LOW);
delay(d3);
digitalWrite(9, LOW);
delay(d3);
digitalWrite(6, LOW);
delay(d3);
digitalWrite(3, LOW); // turn the LEDs off
delay(d3);
}
// xxxxxxxxxxxxxxxxxxx Blue Inc xxxxxxxxxxxxxxx
void s5() { //declare function
// turn the LEDs on
digitalWrite(4, HIGH);
delay(d3);
digitalWrite(7, HIGH);
delay(d3);
digitalWrite(10, HIGH);
delay(d3);
digitalWrite(13, HIGH); // leds on red
delay(d3);
// turn the LEDs off
digitalWrite(4, LOW);
delay(d3);
digitalWrite(7, LOW);
delay(d3);
digitalWrite(10, LOW);
delay(d3);
digitalWrite(13, LOW);; // turn the LEDs off
delay(d3);
}
......and so on...