ArduinoのSketch(Sketch)で、for制御文を使用する方法を解説します。
1 2 3 4 5 6 7 8 |
//Arduino Sketch Example: for loop syntax //Date: 2014.12.28 //Auther: easy labo //Syntax for (initialization; condition; increment) { //statement(s); } |
for文の書式は、C言語と同様です。
initialization: 初期化式
condition: 継続条件式
increment: ループ1回終了後の加算式
1 2 3 4 5 6 7 8 9 |
//Arduino Sketch Example: for loop statement //Date: 2014.12.28 //Auther: easy labo //Sample Code for (int i=0; i <= 10; i++){ // do something here delay(10); } |
上記の例の様に使用する事ができますので、一例として挙げておきます。
Sponsored Link