/* Light up all the LED's in the matrix to test them Nathan Clark */ int delayPin = 1; // delay before it turns the LED off int row[] = {10,11,12,13,A5,A4,A3,A0}; // These are the Cathodes - Send LOW to turn on LED int col[] = {2,3,4,5,6,7,8,9}; // These are the Anodes - Send HIGH to turn on LED void setup() { for (int thisPin = 0; thisPin < 8; thisPin++) { pinMode(col[thisPin], OUTPUT); // Set selected pin to be an output rather then an input pin pinMode(row[thisPin], OUTPUT); // this is so we cna provide +5v or GND at any pin digitalWrite(row[thisPin], HIGH); // Set all cathodes to have positive voltage at them. Hence LED will not light up irrespective of what the anode is set to } } void loop() { onLED(0,0); onLED(1,1); onLED(0,1); onLED(1,0); onLED(6,0); onLED(7,1); onLED(6,1); onLED(7,0); onLED(3,3); onLED(4,3); onLED(3,2); onLED(4,2); onLED(0,5); onLED(1,6); onLED(2,7); onLED(3,7); onLED(4,7); onLED(5,7); onLED(6,6); onLED(7,5); } void resetLEDS() { for (int thisPin = 0; thisPin < 8; thisPin++) { digitalWrite(row[thisPin], HIGH); // Set all cathodes to have positive voltage at them. Hence LED will not light up irrespective of what the anode is set to digitalWrite(col[thisPin], LOW); } } void onLED(int colnum,int rownum) { digitalWrite(col[colnum], HIGH); digitalWrite(row[rownum], LOW); delay(delayPin); digitalWrite(col[colnum], LOW); digitalWrite(row[rownum], HIGH); }