請鍵入下列程式並燒錄至晶片 #define DelayTime 200 #define ROW 8 #define COL 3 #define G1 10 const int scan[COL] = {13,12,11}; const int row[ROW] = {9,8,7,8,9,4,3,2}; void setup() { for (int i = 0;i<COL;i++) pinMode(scan[i], OUTPUT); for (int i = 0;i<ROW;i++) pinMode(row[i], OUTPUT); pinMode(G1, OUTPUT); digitalWrite(G1,LOW); } void loop() { int i, j, k, r, u; for(i=LOW;i<=HIGH;i++) for(j=LOW;j<=HIGH;j++) for(k=LOW;k<=HIGH;k++){ digitalWrite(G1,LOW); digitalWrite(scan[0],k); digitalWrite(scan[1],j); digitalWrite(scan[2],i); for(r=0;r<ROW;r++){ for(u=0;u<ROW;u++) digitalWrite(row[u],(u==r)); digitalWrite(G1,HIGH); delay(DelayTime); } } } |