int cols[5] = {9, 10, 11, 12, 13}; //pins of the coloms int rows[5] = {4, 5, 6, 7, 8}; //pins of the rows void setup() { for (int i = 4; i < 14; i++) { //declare pins as outputs pinMode(i, OUTPUT); } for (int i = 0; i < 5; i++) { digitalWrite (cols[i], HIGH); //set all colom-pins to HIGH digitalWrite (rows[i], LOW); //set all row-pins to LOW } } void loop() { //random leds are blinking for (int x = 0; x < 5; x++) { digitalWrite (cols[x], LOW); for (int i = 0; i < 20; i++) { for (int y = 0; y < 5; y++) { digitalWrite (rows[y], HIGH); delay(1); //reset of the selected pins digitalWrite (rows[y], LOW); delay(1); } } digitalWrite (cols[x], HIGH); } }