Created
June 27, 2009 06:44
-
-
Save koki-h/136928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ナイトライダーその2。とりあえずアナログアウトを使うようにした | |
#define PIN_MIN 0 | |
#define PIN_MAX 5 | |
int apin[] = {3,5,6,9,10,11}; | |
//int number_of_pins = sizeof(apin); //何回も使う値はマクロにして即値にしたほうが速い | |
void setup() | |
{ | |
for (int i = PIN_MIN; i <= PIN_MAX; i++){ | |
pinMode(i, OUTPUT); | |
} | |
} | |
void loop() | |
{ | |
for (int i = PIN_MIN; i <= PIN_MAX ; i++){ | |
analogWrite(apin[i], 100); | |
delay(100); | |
analogWrite(apin[i], 0); | |
} | |
for (int i = PIN_MAX; i >= PIN_MIN; i--){ | |
analogWrite(apin[i], 100); | |
delay(100); | |
analogWrite(apin[i], 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment