voidsetup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600);//串口通信初始,波特率为9600,Serial.begin()表示用的是Serial库里面的begin函数 // make the pushbutton's pin an input: pinMode(pushButton, INPUT); }
// the loop routine runs over and over again forever: voidloop() { // read the input pin: int buttonState = digitalRead(pushButton)//读取引脚2的状态,digitalRead()可以读取引脚是HIGH还是LOW // print out the state of the button: Serial.println(buttonState);//打印串口数据,HIGH为1 LOW为0 delay(1); // delay in between reads for stability }