Skip to content

Instantly share code, notes, and snippets.

@ssov
Created February 15, 2012 01:56
Show Gist options
  • Save ssov/1832471 to your computer and use it in GitHub Desktop.
Save ssov/1832471 to your computer and use it in GitHub Desktop.
あれの〄のあれ
// 点灯時間
const int msec = 1;
const int num = 8;
const int row[num] = {11, 12, 14, 15, 16, 17, 18, 19};
const int col[num] = {2, 3, 4, 5, 6, 7, 8, 9};
void setup() {
for (int i = 0; i < num; i++)
pinMode(row[i], OUTPUT); // 行側のピンの初期化
for (int i = 0; i < num; i++)
pinMode(col[i], OUTPUT); // 列側のピンの初期化
}
void loop() {
for (int i = 0; i < num; i++) {
digitalWrite(col[i], HIGH); // 各行を HIGH に
for (int j = 0; j < num; j++) {
digitalWrite(row[j], LOW); // 各列を LOW に(点灯させる)
delay(msec); // 点灯時間だけ待つ
}
digitalWrite(col[i], LOW); // 各行を LOW に
}
for (int i = num-1; i >= 0; i--) {
digitalWrite(col[i], HIGH); // 各行を HIGH に
for (int j = num-1; j >= 0; j--) {
digitalWrite(row[j], LOW); // 各列を LOW に(点灯させる)
delay(msec); // 点灯時間だけ待つ
}
digitalWrite(col[i], LOW); // 各行を LOW に
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment