Not sure if this will work (I am at a work computer) but I'm going to try it when I get back.
//Setup the timing variables
long onInterval = 250;
long offInterval = 100;
long interval = onInterval;
//Track the last time the time was updated
long lastMillis = millis();
//Variable to track where in the pattern we are
int flashPatternStepper = 0;
//Variable to track which pattern is being used
int flashPatternSelect = 0;
//Array of possible flash patterns
int [][] flashPatterns = {{1, 0, 2, 0},
{1, 2, 1, 2}};
//Variables to track color selection
char color1 = 'r';
char color2 = 'b';
//Pins for the RGB LED
int redPin = 9;
int greenPin = 10;
int bluePin = 11;
//Normal setup just setting pin modes
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
//loop() only calls the handleLEDs function for now
void loop()
{
handleLEDs();
//Code to change values of flashPatternSelect, onInterval, offInterval, color1, and color2
}
void handleLEDs()
{
//Check to see if lights should be on or off
if(flashPatterns[flashPatternSelect][flashPatternStepper] == 0)
{
interval = offInterval
}
else
{
interval = onInterval;
}
//Check if we need to advance flashPatternStepper to the next place in the sequence
if(millis() - lastMillis > interval)
{
lastMillis = millis();
flashPatternStepper++;
if(flashPatternStepper > flashPatterns.length-1)
{
flashPatternStepper = 0;
}
}
//colorSelect decides which LED Pins should be active, if any
colorSelect();
}
//Control the colors
void colorSelect()
{
char colorChoice;
///Set colorChoice based on where we are in the sequence
switch (flashPattern[flashPatternSelect][flashPatternStepper])
{
case 1:
colorChoice = color1;
break;
case 2:
colorChoice = color2;
break;
case 0:
colorChoice = 'o';
break;
}
//Actually turn on/off the LED pin(s)
switch(colorChoice)
{
case 'y':
digitalWrite(redPin, LOW);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, HIGH);
break;
case 'w':
digitalWrite(redPin, LOW);
digitalWrite(greenPin, LOW);
arduino.digitalWrite(bluePin, LOW);
break;
case 'r':
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, HIGH);
break;
case 'g':
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, HIGH);
break;
case 'b':
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, LOW);
break;
case 'p':
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, LOW);
break;
case 'c':
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, LOW);
break;
case 'o':
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, HIGH);
break;
}
}
Hopefully I can build from this to what I need.