Loading...

Reference   Language | Libraries | Comparison | Changes

setup()

程序刚启动时,调用setup()函数.用于初始化变量,设置针脚的输出/输入类型,配置串口,引入库文件等等. 每次Arduino上电或重启后,setup函数只运行一次.

例子

 
int buttonPin = 3;

void setup()
{
  Serial.begin(9600);
  pinMode(buttonPin, INPUT);
}

void loop()
{
  // ...
}

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.