Hi,
I stumbled across this old code in the internet and would like to use it for a model that I am building, but have a hard time to figure out the correct wiring, which is long gone. I am using a Arduino Pro Mini. The left and the right light bar is moving contrary, like in this video: 1/18 Knight Rider Shelby GT500 with full working lights - YouTube.
If someone could help out with a wiring diagram (breadbord etc.) to make my project work I’m willing to donate.
int cycleTime = 500;
int pins[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
int numPins = 11;
int numCycles = 59;
int cycle = 0;
int pinDigital[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int pinStatus[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int pinIntensity[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int intensityCurve[] = {101, 95, 85, 75, 50,0};
int intensityMark = 50;
int timer = 0;
int cycleDefs[59][11] =
{
// {5,0,5,0,5,0,5,0,5},
// {0,0,5,5,5,5,0,0,0},
{2,0,0,0,0,0,0,0,0,0,0},
{2,1,0,0,0,0,0,0,0,0,0},
{3,2,1,0,0,0,0,0,0,0,0},
{4,3,2,1,0,0,0,0,0,0,0},
{5,4,3,2,1,0,0,0,0,0,0},
{5,5,4,3,2,1,0,0,0,0,0},
{5,5,5,4,3,2,1,0,0,0,0},
{5,5,5,5,4,3,2,1,0,0,0},
{5,5,5,5,5,4,3,2,1,0,0},
{5,5,5,5,5,5,4,3,2,1,0},
{5,5,5,5,5,5,5,4,3,2,1},
{5,5,5,5,5,5,5,5,4,3,2},
{5,5,5,5,5,5,5,5,5,4,3},
{5,5,5,5,5,5,5,5,5,5,4},
{5,5,5,5,5,5,5,5,5,5,5},
{5,5,5,5,5,5,5,5,5,5,5},
{4,5,5,5,5,5,5,5,5,5,5},
{3,4,5,5,5,5,5,5,5,5,5},
{2,3,4,5,5,5,5,5,5,5,5},
{1,2,3,4,5,5,5,5,5,5,5},
{0,1,2,3,4,5,5,5,5,5,5},
{0,0,1,2,3,4,5,5,5,5,5},
{0,0,0,1,2,3,4,5,5,5,5},
{0,0,0,0,1,2,3,4,5,5,5},
{0,0,0,0,0,1,2,3,4,5,5},
{0,0,0,0,0,0,1,2,3,4,5},
{0,0,0,0,0,0,0,1,2,3,4},
{0,0,0,0,0,0,0,0,1,2,3},
{0,0,0,0,0,0,0,0,0,1,2},
{0,0,0,0,0,0,0,0,0,0,2},
// {5,0,5,0,5,0,5,0,5},
{0,0,0,0,0,0,0,0,0,0,2},
{0,0,0,0,0,0,0,0,0,1,2},
{0,0,0,0,0,0,0,0,1,2,3},
{0,0,0,0,0,0,0,1,2,3,4},
{0,0,0,0,0,0,1,2,3,4,5},
{0,0,0,0,0,1,2,3,4,5,5},
{0,0,0,0,1,2,3,4,5,5,5},
{0,0,0,1,2,3,4,5,5,5,5},
{0,1,2,3,4,5,5,5,5,5,5},
{1,2,3,4,5,5,5,5,5,5,5},
{4,4,4,5,5,5,5,5,5,5,5},
{4,5,5,5,5,5,5,5,5,5,5},
{5,5,5,5,5,5,5,5,5,5,5},
{5,5,5,5,5,5,5,5,5,5,5},
{5,5,5,5,5,5,5,5,5,5,5},
{5,5,5,5,5,5,5,5,5,5,4},
{5,5,5,5,5,5,5,5,5,4,3},
{5,5,5,5,5,5,5,5,4,3,2},
{5,5,5,5,5,5,5,4,3,2,1},
{5,5,5,5,5,5,4,3,2,1,0},
{5,5,5,5,5,4,3,2,1,0,0},
{5,5,5,5,4,3,2,1,0,0,0},
{5,5,5,4,3,2,1,0,0,0,0},
{5,5,4,3,2,1,0,0,0,0,0},
{5,4,3,2,1,0,0,0,0,0,0},
{4,3,2,1,0,0,0,0,0,0,0},
{3,2,1,0,0,0,0,0,0,0,0},
{2,1,0,0,0,0,0,0,0,0,0},
{2,0,0,0,0,0,0,0,0,0,0}
};
void setup()
{
int i;
// Serial.begin(9600);
// Serial.println("Program Loaded");
for (i = 0; i < numPins; i++)
{
pinMode(pins[i], OUTPUT);
}
pinMode(13,OUTPUT);
}
void loop()
{
int i;
int tmp;
timer++;
if((timer % intensityMark)==0)
{
for(i = 0; i<numPins; i++)
{
int targetIntensity = intensityCurve[pinStatus[i]];
if(targetIntensity > pinIntensity[i])
{
pinIntensity[i]++;
}
else if(targetIntensity < pinIntensity[i])
{
pinIntensity[i]--;
}
}
}
for (i = 0; i < numPins; i++)
{
if((timer % intensityMark) >= pinIntensity[i])
{
if(pinDigital[i] == 0)
{
pinDigital[i] = 1;
digitalWrite(pins[i],HIGH);
}
}
else
{
if(pinDigital[i] == 1)
{
pinDigital[i] = 0;
digitalWrite(pins[i],LOW);
}
}
}
if(timer == cycleTime)
{
timer = 0;
cycle++;
}
else
{
return;
}
// Serial.read();
if(cycle >= (numCycles))
{
cycle = 0;
digitalWrite(13,HIGH);
}
if(cycle == 20)
{
digitalWrite(13,LOW);
}
for(i=0; i<numPins; i++)
{
pinStatus[i] = cycleDefs[cycle][i];
}
}