Page 332 - 최강 아두이노 퍼스트 참고서
P. 332

clearLeds();

                   // Turn off toggling of pin 11
                   FrequencyTimer2::disable();
                   // Set refresh rate (interrupt timeout period)
                   FrequencyTimer2::setPeriod(2000);
                   // Set interrupt routine to be called
                   FrequencyTimer2::setOnOverflow(display);

                   setPattern(pattern);
                 }

                 void loop() {
                     pattern = ++pattern % numPatterns;
                     slidePattern(pattern, 100);
                 }

                 void clearLeds() {
                   // Clear display array
                   for (int i = 0; i < 8; i++) {
                     for (int j = 0; j < 8; j++) {
                       leds[i][j] = 0;
                     }
                   }
                 }

                 void setPattern(int pattern) {
                   for (int i = 0; i < 8; i++) {
                     for (int j = 0; j < 8; j++) {
                       leds[i][j] = patterns[pattern][i][j];
                     }
                   }
                 }

                 void slidePattern(int pattern, int del) {
                   for (int l = 0; l < 8; l++) {
                     for (int i = 0; i < 7; i++) {
                       for (int j = 0; j < 8; j++) {
                         leds[j][i] = leds[j][i+1];
                       }
                     }
                     for (int j = 0; j < 8; j++) {
                       leds[j][7] = patterns[pattern][j][0 + l];
                     }
                     delay(del);
                   }
                 }


                 // Interrupt routine





                                                   332
   327   328   329   330   331   332   333   334   335   336   337