| | 1 | [[PageOutline]] |
| | 2 | |
| | 3 | = 程式一 = |
| | 4 | {{{ |
| | 5 | /* |
| | 6 | Blink |
| | 7 | Turns on an LED on for one second, then off for one second, repeatedly. |
| | 8 | |
| | 9 | This example code is in the public domain. |
| | 10 | */ |
| | 11 | |
| | 12 | void setup() { |
| | 13 | // initialize the digital pin as an output. |
| | 14 | // Pin 13 has an LED connected on most Arduino boards: |
| | 15 | pinMode(2, OUTPUT); |
| | 16 | pinMode(3, OUTPUT); |
| | 17 | pinMode(4, OUTPUT); |
| | 18 | pinMode(5, OUTPUT); |
| | 19 | pinMode(6, OUTPUT); |
| | 20 | pinMode(7, OUTPUT); |
| | 21 | pinMode(8, OUTPUT); |
| | 22 | pinMode(9, OUTPUT); |
| | 23 | } |
| | 24 | |
| | 25 | void loop() { |
| | 26 | digitalWrite(2, HIGH); // set the LED on |
| | 27 | delay(300); // wait for a second |
| | 28 | digitalWrite(2, LOW); // set the LED off |
| | 29 | delay(300); // wait for a second |
| | 30 | |
| | 31 | digitalWrite(3, HIGH); // set the LED on |
| | 32 | delay(300); // wait for a second |
| | 33 | digitalWrite(3, LOW); // set the LED off |
| | 34 | delay(300); // wait for a second |
| | 35 | |
| | 36 | digitalWrite(4, HIGH); // set the LED on |
| | 37 | delay(300); // wait for a second |
| | 38 | digitalWrite(4, LOW); // set the LED off |
| | 39 | delay(300); // wait for a second |
| | 40 | |
| | 41 | digitalWrite(5, HIGH); // set the LED on |
| | 42 | delay(300); // wait for a second |
| | 43 | digitalWrite(5, LOW); // set the LED off |
| | 44 | delay(300); // wait for a second |
| | 45 | |
| | 46 | digitalWrite(6, HIGH); // set the LED on |
| | 47 | delay(300); // wait for a second |
| | 48 | digitalWrite(6, LOW); // set the LED off |
| | 49 | delay(300); // wait for a second |
| | 50 | |
| | 51 | digitalWrite(7, HIGH); // set the LED on |
| | 52 | delay(300); // wait for a second |
| | 53 | digitalWrite(7, LOW); // set the LED off |
| | 54 | delay(300); // wait for a second |
| | 55 | |
| | 56 | digitalWrite(8, HIGH); // set the LED on |
| | 57 | delay(300); // wait for a second |
| | 58 | digitalWrite(8, LOW); // set the LED off |
| | 59 | delay(300); // wait for a second |
| | 60 | |
| | 61 | digitalWrite(9, HIGH); // set the LED on |
| | 62 | delay(300); // wait for a second |
| | 63 | digitalWrite(9, LOW); // set the LED off |
| | 64 | delay(300); // wait for a second |
| | 65 | |
| | 66 | } |
| | 67 | }}} |