//Arduino Sketch Example: Variable Scope
//Date: 2015.1.12
//Edited and Modified by: easy labo
//Original Source: Arduino Reference (

int glovalVal;  // (A) any function will see this variable

void setup()
  // ...

void loop()
  int i;  // (B) "i" is only "visible" inside of "loop"
  // ...

  for (int j = 0; j <10; j++){
  // (C) variable j can only be accessed inside the for-loop brackets


Creative Commons Attribution-ShareAlike 3.0 License (CC BY-SA 3.0)
Arduino Reference:Variable Scope” by Arduino Team, used under CC BY-SA 3.0/ easy labo made some changes and comments to the original


スコープの境界は、{ … } なので、その事に注意してSketch(スケッチ)をプログラミングしていきましょう。


Sponsored Link