Changes between Version 2 and Version 3 of wade/embedded/arduino/example/example_1
- Timestamp:
- Jan 14, 2010, 4:27:52 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
wade/embedded/arduino/example/example_1
v2 v3 1 1 {{{ 2 2 /* 3 * 讓三顆 LED 輪流亮起來 3 * 讓三顆 LED 輪流亮起來,LOW 會導通電路 4 4 */ 5 5 6 #define pin1 8// 定義 LED 腳位7 #define pin2 4// 定義 LED 腳位8 #define pin3 13// 定義 LED 腳位6 #define r 3 // 定義 LED 腳位 7 #define g 5 // 定義 LED 腳位 8 #define b 6 // 定義 LED 腳位 9 9 #define delay_time 1000 // 定義延遲時間 10 10 … … 12 12 void setup() 13 13 { 14 pinMode(pin1, OUTPUT); 15 pinMode(pin2, OUTPUT); 16 pinMode(pin3, OUTPUT); 14 pinMode(r, OUTPUT); 15 pinMode(g, OUTPUT); 16 pinMode(b, OUTPUT); 17 digitalWrite(r, HIGH); 18 digitalWrite(g, HIGH); 19 digitalWrite(b, HIGH); 17 20 } 18 21 … … 21 24 { 22 25 // pin1 閃爍 23 digitalWrite( pin1, HIGH);26 digitalWrite(r, LOW); 24 27 delay(delay_time); 25 digitalWrite(r, LOW);28 digitalWrite(r, HIGH); 26 29 delay(delay_time); 27 30 28 31 // pin2 閃爍 32 digitalWrite(g, LOW); 33 delay(delay_time); 29 34 digitalWrite(g, HIGH); 30 delay(delay_time);31 digitalWrite(g, LOW);32 35 delay(delay_time); 33 36 34 37 // pin3 閃爍 38 digitalWrite(b, LOW); 39 delay(delay_time); 35 40 digitalWrite(b, HIGH); 36 41 delay(delay_time); 37 digitalWrite(b, LOW);38 delay(delay_time);39 42 } 43 40 44 }}}