I've been learning how to program this fine piece of equipment but i seem stuck. I came upon the "Knight rider" example where you are supposed to blink LED's from one side to another and i can't understand where some of the code comes from. For example:
byte ledPin[] = {4,5,6,7,8,9,10,11,12,13};
int ledDelay;
int direction = 1;
int currentLED = 0;
unsigned long changeTime;
int pot = 2;
int i;
void setup()
{
Serial.begin(9600);
for (i = 0; i < 10; i++)
{
pinMode(ledPin[i], OUTPUT);
}
changeTime = millis();
}
void loop()
{
ledDelay = analogRead(pot);
if ((millis()- changeTime) > ledDelay)
{
changeLED();
changeTime = millis();
}
}
void changeLED()
{
for (i = 0; i < 10; i++)
{
digitalWrite(ledPin[i], LOW);
Serial.print("i = ");
Serial.println(i);
}
digitalWrite(ledPin[currentLED], HIGH);
currentLED += direction;
if (currentLED == 9)
{
direction = -1;
}
if (currentLED == 0)
{
direction = 1;
}
}
In this code I don't know where the "direction" variable is coming from I searched on the arduino reference page but can't find it. Are there other references where I could look or am I misunderstanding something?