iam郎 发表于 2015-3-17 17:56:18

【iam学代码】模拟串口读取

/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
模拟串口读取程序,读取A0接口的数据,然后在串口监视器上显示结果。把滑动变阻器的中间脚
接到A0脚上,其余的接口分别接地gnd和5v

This example code is in the public domain. 公开的
*/

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1);      // delay in between reads for stability
}
页: [1]
查看完整版本: 【iam学代码】模拟串口读取