#define TRUE 1
#define FALSE 0
const int numLEDs = 4;
const int GPIO_Pins[] = {2,3,4,5};
const int runRate = 200;
static bool direction = TRUE;
void setup() {
// put your setup code here, to run once:
for (int led = 0; led < numLEDs; led++)
{
pinMode(GPIO_Pins[led], OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
runningLEDs(runRate, direction);
direction = !direction;
}
void runningLEDs(int runRate, bool direction)
{
if(direction == TRUE) {
for (int led = 0; led < numLEDs; led++)
{
digitalWrite(GPIO_Pins[led], HIGH);
delay(runRate);
digitalWrite(GPIO_Pins[led], LOW);
//delay(runRate);
}
}
else {
for (int led = numLEDs-1; led >= 0; led--)
{
digitalWrite(GPIO_Pins[led], HIGH);
delay(runRate);
digitalWrite(GPIO_Pins[led], LOW);
//delay(runRate);
}
}
}