Version 4 (modified by wade, 12 years ago) (diff) |
---|
程式一
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); } void loop() { digitalWrite(2, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(2, LOW); // set the LED off delay(300); // wait for a second digitalWrite(3, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(3, LOW); // set the LED off delay(300); // wait for a second digitalWrite(4, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(4, LOW); // set the LED off delay(300); // wait for a second digitalWrite(5, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(5, LOW); // set the LED off delay(300); // wait for a second digitalWrite(6, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(6, LOW); // set the LED off delay(300); // wait for a second digitalWrite(7, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(7, LOW); // set the LED off delay(300); // wait for a second digitalWrite(8, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(8, LOW); // set the LED off delay(300); // wait for a second digitalWrite(9, HIGH); // set the LED on delay(300); // wait for a second digitalWrite(9, LOW); // set the LED off delay(300); // wait for a second }
程式二
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(14, OUTPUT); pinMode(15, OUTPUT); pinMode(16, OUTPUT); pinMode(17, OUTPUT); digitalWrite(10, HIGH); digitalWrite(11, HIGH); digitalWrite(12, HIGH); digitalWrite(13, HIGH); digitalWrite(14, HIGH); digitalWrite(15, HIGH); digitalWrite(16, HIGH); digitalWrite(17, HIGH); } void loop() { // time 1 digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW); digitalWrite(13, LOW); digitalWrite(14, LOW); digitalWrite(15, LOW); digitalWrite(16, LOW); digitalWrite(17, LOW); // delay(300); clean(); // time 2 // digitalWrite(3, HIGH); // HIGH // delay(300); // wait for a second // digitalWrite(3, LOW); // set the LED off // delay(300); // wait for a second // // // time 3 // digitalWrite(4, HIGH); // set the LED on // delay(300); // wait for a second // digitalWrite(4, LOW); // set the LED off // delay(300); // wait for a second // // // time 4 // digitalWrite(5, HIGH); // set the LED on // delay(300); // wait for a second // digitalWrite(5, LOW); // set the LED off // delay(300); // wait for a second // // // time 5 // digitalWrite(6, HIGH); // set the LED on // delay(300); // wait for a second // digitalWrite(6, LOW); // set the LED off // delay(300); // wait for a second // // // time 6 // digitalWrite(7, HIGH); // set the LED on // delay(300); // wait for a second // digitalWrite(7, LOW); // set the LED off // delay(300); // wait for a second // // // time 7 // digitalWrite(8, HIGH); // set the LED on // delay(300); // wait for a second // digitalWrite(8, LOW); // set the LED off // delay(300); // wait for a second // // time 8 // digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH digitalWrite(9, HIGH); // HIGH digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW); digitalWrite(13, LOW); digitalWrite(14, LOW); digitalWrite(15, LOW); digitalWrite(16, LOW); digitalWrite(17, LOW); // delay(300); clean(); } void clean() { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, HIGH); digitalWrite(11, HIGH); digitalWrite(12, HIGH); digitalWrite(13, HIGH); digitalWrite(14, HIGH); digitalWrite(15, HIGH); digitalWrite(16, HIGH); digitalWrite(17, HIGH); }
程式三
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(14, OUTPUT); pinMode(15, OUTPUT); pinMode(16, OUTPUT); pinMode(17, OUTPUT); digitalWrite(10, HIGH); digitalWrite(11, HIGH); digitalWrite(12, HIGH); digitalWrite(13, HIGH); digitalWrite(14, HIGH); digitalWrite(15, HIGH); digitalWrite(16, HIGH); digitalWrite(17, HIGH); } void loop() { // time 1 digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH // digitalWrite(9, HIGH); // HIGH digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW); digitalWrite(13, LOW); digitalWrite(14, LOW); digitalWrite(15, LOW); digitalWrite(16, LOW); digitalWrite(17, LOW); // delay(300); clean(); // time 2 // digitalWrite(2, HIGH); // HIGH digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH // digitalWrite(9, HIGH); // HIGH // digitalWrite(10, LOW); // digitalWrite(11, LOW); // digitalWrite(12, LOW); digitalWrite(13, LOW); // digitalWrite(14, LOW); // digitalWrite(15, LOW); // digitalWrite(16, LOW); // digitalWrite(17, LOW); // delay(300); clean(); // // // time 3 // digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH // digitalWrite(9, HIGH); // HIGH // digitalWrite(10, LOW); // digitalWrite(11, LOW); // digitalWrite(12, LOW); digitalWrite(13, LOW); // digitalWrite(14, LOW); // digitalWrite(15, LOW); // digitalWrite(16, LOW); // digitalWrite(17, LOW); // delay(300); clean(); // // // time 4 // digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH // digitalWrite(10, LOW); // digitalWrite(11, LOW); // digitalWrite(12, LOW); digitalWrite(13, LOW); // digitalWrite(14, LOW); // digitalWrite(15, LOW); // digitalWrite(16, LOW); // digitalWrite(17, LOW); // delay(300); clean(); // // // time 5 // digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW); digitalWrite(13, LOW); digitalWrite(14, LOW); digitalWrite(15, LOW); digitalWrite(16, LOW); digitalWrite(17, LOW); // delay(300); clean(); // // // time 6 // digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH // digitalWrite(10, LOW); // digitalWrite(11, LOW); // digitalWrite(12, LOW); digitalWrite(13, LOW); // digitalWrite(14, LOW); // digitalWrite(15, LOW); // digitalWrite(16, LOW); // digitalWrite(17, LOW); // delay(300); clean(); // // // time 7 // digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH digitalWrite(8, HIGH); // HIGH // digitalWrite(9, HIGH); // HIGH // digitalWrite(10, LOW); // digitalWrite(11, LOW); // digitalWrite(12, LOW); digitalWrite(13, LOW); // digitalWrite(14, LOW); // digitalWrite(15, LOW); // digitalWrite(16, LOW); // digitalWrite(17, LOW); // delay(300); clean(); // // time 8 // digitalWrite(2, HIGH); // HIGH // digitalWrite(3, HIGH); // HIGH // digitalWrite(4, HIGH); // HIGH // digitalWrite(5, HIGH); // HIGH // digitalWrite(6, HIGH); // HIGH // digitalWrite(7, HIGH); // HIGH // digitalWrite(8, HIGH); // HIGH digitalWrite(9, HIGH); // HIGH digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW); digitalWrite(13, LOW); digitalWrite(14, LOW); digitalWrite(15, LOW); digitalWrite(16, LOW); digitalWrite(17, LOW); clean(); } void clean() { delay(300); digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, HIGH); digitalWrite(11, HIGH); digitalWrite(12, HIGH); digitalWrite(13, HIGH); digitalWrite(14, HIGH); digitalWrite(15, HIGH); digitalWrite(16, HIGH); digitalWrite(17, HIGH); }
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.