Version 7 (modified by wade, 12 years ago) (diff) |
---|
程式一:LED 矩陣測試程式
#define start_pin 2 #define end_pin 18 #define low_start_pin 10 #define low_end_pin 17 #define high_start_pin 2 #define high_end_pin 9 #define led_delay_time 150 #define button 2 boolean flag; void setup() { for (int i=start_pin; i<=end_pin; i++) { pinMode(i, OUTPUT); } // pinMode(button, INPUT); // digitalWrite(button, HIGH); // attachInterrupt(0, button_event, LOW); Serial.begin(9600); clean(); } void loop() { clean(); delay(led_delay_time); for (int i=high_start_pin; i<=high_end_pin; i++) { Serial.print("["); Serial.print(i); Serial.println("] "); digitalWrite(i, HIGH); for (int j=low_start_pin; j<=low_end_pin; j++) { Serial.print(" "); Serial.print(j); digitalWrite(j, LOW); delay(led_delay_time); digitalWrite(j, HIGH); } Serial.println(); digitalWrite(i, LOW); } } void clean() { Serial.println("clean"); for (int i=low_start_pin; i<=low_end_pin; i++) digitalWrite(i, HIGH); for (int i=high_start_pin; i<=high_end_pin; i++) digitalWrite(i, LOW); } void button_event() { delay(500); flag = !flag; while(flag) { } }
程式二:產生「王」字
Attachments (5)
- 2013-05-09-arduino.pdf (2.6 MB) - added by wade 12 years ago.
- LED8x8-2.png (32.6 KB) - added by wade 11 years ago.
- 四方型.png (74.2 KB) - added by wade 11 years ago.
- 米與井.png (34.2 KB) - added by wade 11 years ago.
- 箭頭.png (76.9 KB) - added by wade 11 years ago.