| 1 | {{{ |
| 2 | /* |
| 3 | * 由 11 pins 控制 8 * 8 矩陣式 led matrix |
| 4 | */ |
| 5 | |
| 6 | #define pin0 0 // 定義 LED 腳位 |
| 7 | #define pin1 1 // 定義 LED 腳位 |
| 8 | #define pin2 2 // 定義 LED 腳位 |
| 9 | #define delay_time 500 // 定義延遲時間 |
| 10 | |
| 11 | // 初始設定 |
| 12 | void setup() |
| 13 | { |
| 14 | pinMode(pin0 , OUTPUT); |
| 15 | pinMode(pin1 , OUTPUT); |
| 16 | pinMode(pin2 , OUTPUT); |
| 17 | digitalWrite(pin0, LOW); |
| 18 | digitalWrite(pin1, LOW); |
| 19 | digitalWrite(pin2, LOW); |
| 20 | } |
| 21 | |
| 22 | // 主程式迴圈 |
| 23 | void loop() |
| 24 | { |
| 25 | // HEX 000 |
| 26 | digitalWrite(pin0, LOW); |
| 27 | digitalWrite(pin1, LOW); |
| 28 | digitalWrite(pin2, LOW); |
| 29 | delay(delay_time); |
| 30 | |
| 31 | // HEX 001 |
| 32 | digitalWrite(pin0, HIGH); |
| 33 | digitalWrite(pin1, LOW); |
| 34 | digitalWrite(pin2, LOW); |
| 35 | delay(delay_time); |
| 36 | |
| 37 | // HEX 010 |
| 38 | digitalWrite(pin0, LOW); |
| 39 | digitalWrite(pin1, HIGH); |
| 40 | digitalWrite(pin2, LOW); |
| 41 | delay(delay_time); |
| 42 | |
| 43 | // HEX 011 |
| 44 | digitalWrite(pin0, HIGH); |
| 45 | digitalWrite(pin1, HIGH); |
| 46 | digitalWrite(pin2, LOW); |
| 47 | delay(delay_time); |
| 48 | |
| 49 | // HEX 100 |
| 50 | digitalWrite(pin0, LOW); |
| 51 | digitalWrite(pin1, LOW); |
| 52 | digitalWrite(pin2, HIGH); |
| 53 | delay(delay_time); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | }}} |