I don't know if this helps, but this was the code I wrote about four years ago for a led strobe controller for a quadcopter, which was based on an ATTiny85, so should be easy to transfer to a Digispark. It was plugged into an auxiliary channel of the quads receiver, so the pattern to be used was controlled by the transmitter.
I know it is a let more complicated than the sketch that exeng gave earlier, but it does a lot more, and shows one way to control multiple pins with multiple pattern sets. Unfortunately, I can't say for certain whether I finished this version of the code, and I see there is some code in it from the previous revision that is now redundant / not needed.
/*
PIN 0 / STARBOARD / RIGHT / GREEN
PIN 1 / STROBE / REAR / WHITE
PIN 2 / PORT / LEFT / RED
PIN 4 / RC_SIGNAL / RC RECEIVER
*/
#define STARBOARD 0
#define STROBE 1
#define PORT 2
#define RC_SIGNAL 4
#define NUM_PATTERNS 5
long currentMillis;
int rcSignal = 0;
byte currMode = 0;
byte lastMode = 25;
PROGMEM prog_uchar masterPatternStates[NUM_PATTERNS][3][10] = { {{0,255}, {0,255}, {0,255}},
{{1,0,255}, {0,1,0,255}, {0,1,0,255}},
{{0,255}, {1,0,1,0,255}, {0,255}},
{{1,0,1,255}, {1,0,1,255}, {0,1,0,1,255}},
{{0,1,255}, {0,1,255}, {1,0,255}}
};
PROGMEM prog_uint16_t masterPatternTimes[NUM_PATTERNS][3][10] = { {{0}, {0}, {0}},
{{50,1200}, {100,50,1100}, {200,50,1000}},
{{0}, {50,100,50,100}, {0}},
{{1000,50,500}, {500,50,1000}, {1200,75,150,75}},
{{1900,100}, {1900,100}, {1800,200}}
};
unsigned char pattern_states[3][10];
//
/* = {{0,1,0,1,0,1,0,1,0,255},
{0,1,0,1,0,1,0,1,0,255},
{0,1,0,1,0,1,0,1,0,255}}; //(1 byte) 0 to 255
uint16_t pattern_times[3][10]; //(2 bytes) 0 to 65,535
*/
int portPattern[5][10] = {
{0,0,-1},
{1,50,0,1200,-1},
{0,0,-1},
{1,1000,0,50,1,500,-1},
{0,1900,1,100,-1}
};
int starboardPattern[5][10] = {
{0,0,-1},
{0,100,1,50,0,1100,-1},
{1,50,0,100,1,50,0,100,-1},
{1,500,0,50,1,1000,-1},
{0,1900,1,100,-1}
};
int strobePattern[5][10] = {
{0,0,-1},
{0,200,1,50,0,1000,-1},
{0,0,-1},
{0,1200,1,75,0,150,1,75,-1},
{1,1800,0,200,-1}
};
unsigned long strobe[4] = {1,0,0,0};
unsigned long port[4] = {1,0,0,0};
unsigned long starboard[4] = {1,0,0,0};
void setup()
{
pinMode(PORT,OUTPUT);
pinMode(STARBOARD,OUTPUT);
pinMode(STROBE,OUTPUT);
pinMode(RC_SIGNAL,INPUT);
digitalWrite(PORT,LOW);
digitalWrite(STARBOARD,LOW);
digitalWrite(STROBE,LOW);
}
void loop()
{
rcSignal = pulseIn(RC_SIGNAL, HIGH, 25000);
if (rcSignal < 900) // spektrum smartsafe or no valid signal
{
currMode = 1; //chaser - no signal
}
else if (rcSignal >= 900 && rcSignal <= 1300) //low
{
currMode = 0; //off
}
else if (rcSignal > 1300 && rcSignal <= 1700) // middle
{
currMode = 3; //pattern 1
}
else if (rcSignal > 1700 && rcSignal <= 2100) //high
{
currMode = 4; //pattern 2
}
else //I don't understand?
{
currMode = 2;
}
if (currMode != lastMode)
{
//load new pattern table
for (int i = 0; i < NUM_PATTERNS; i++)
{
for (int j = 0; j < 3; j++)
{
pattern_states[i][j] = pgm_read_word(&masterPatternStates[currMode][i][j]);
}
}
//reset counters
// [0] mode, [1] firstRun, [2] step, [3] waitTime
port[0] = currMode; port[1] = 0; port[2] = 0;
starboard[0] = currMode; starboard[1] = 0; starboard[2] = 0;
strobe[0] = currMode; strobe[1] = 0; strobe[2] = 0;
digitalWrite(PORT,LOW);
digitalWrite(STARBOARD,LOW);
digitalWrite(STROBE,LOW);
lastMode = currMode;
}
currentMillis = millis();
//port light
if (port[1] == 0 || currentMillis >= port[3])
{
if (port[1] == 0)
port[1] = 1;
if (portPattern[port[0]][port[2]] == 0)
{
digitalWrite(PORT,LOW);
}
else //if (portPattern[port[0]][port[2]] == 1)
{
digitalWrite(PORT,HIGH);
}
port[3] = millis() + portPattern[port[0]][port[2]+1];
port[2] += 2;
if (portPattern[port[0]][port[2]] == -1)
{
port[2] = 0;
}
}
//starboard light
if (starboard[1] == 0 || currentMillis >= starboard[3]) //[3] is delay
{
if (starboard[1] == 0)
starboard[1] = 1;
if (starboardPattern[starboard[0]][starboard[2]] == 0) //[2] is on/off flag
{
digitalWrite(STARBOARD,LOW); // light off
}
else //(starboardPattern[starboard[0]][starboard[2]] == 1) //[2] is on/off flag
{
digitalWrite(STARBOARD,HIGH); // light on
}
starboard[3] = currentMillis + starboardPattern[starboard[0]][starboard[2]+1]; //read 'delay' parameter
starboard[2] += 2; //increment to next 'step'
if (starboardPattern[starboard[0]][starboard[2]] == -1) // if next 'step' is '-1' - end of set
{
starboard[2] = 0; // return to first instruction in set
}
}
if (strobe[1] == 0 || currentMillis >= strobe[3])
{
if (strobe[1] == 0)
strobe[1] = 1;
if (strobePattern[strobe[0]][strobe[2]] == 0)
{
digitalWrite(STROBE,LOW);
}
else if (strobePattern[strobe[0]][strobe[2]] == 1)
{
digitalWrite(STROBE,HIGH);
}
strobe[3] = currentMillis + strobePattern[strobe[0]][strobe[2]+1];
strobe[2] += 2;
if (strobePattern[strobe[0]][strobe[2]] == -1)
{
strobe[2] = 0;
}
}
}