Strobe all the LEDs

 

/// arduino pin defines
#define RED A1
#define GREEN A0
#define BLUE A2
#define LED1 2
#define LED2 3
#define LED3 4
#define LED4 5
#define LED5 6
#define LED6 7
#define LED7 8
#define LED8 9

uint8_t led_anodes[] = {LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8};
uint8_t led_cathodes[] = {RED, GREEN, BLUE};

void setup() {
// put your setup code here, to run once:
// pin direction setup
pinMode(RED, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(GREEN, OUTPUT);

pinMode(LED8, OUTPUT);
pinMode(LED7, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED1, OUTPUT);

// default off
digitalWrite(RED, LOW);
digitalWrite(BLUE, LOW);;
digitalWrite(GREEN, LOW);

digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
digitalWrite(LED5, LOW);
digitalWrite(LED6, LOW);
digitalWrite(LED7, LOW);
digitalWrite(LED1, LOW);

 // Strobe all the LEDs (a nice easy test
 for (uint8_t c=0; c<3; c++) {
   // turn on one color at a time
   digitalWrite(led_cathodes[c], HIGH);
   for (uint8_t a=0; a<8; a++) {
     // turn on one LED at a time
     digitalWrite(led_anodes[a], HIGH);
     delay(30);
   }
   // turn it off
   digitalWrite(led_cathodes[c], LOW);
   for (uint8_t a=0; a<8; a++) {
     digitalWrite(led_anodes[a], LOW);
   }
 }

}

void loop() {
// put your main code here, to run repeatedly:

}