我知道这是一个简单的问题,答案非常简单,但我是一个初学者,我认为我甚至无法有效地谷歌。所以请耐心等待。
我只是在为arduino寻找某种诊断软件。不是虚拟环境,我想测试控制器本身。具体来说,我正在学习I / O和模拟信号,想要测试我连接的旋转电位器是否在我转动时向控制器发送0-255值(如编程)。
有没有人拥有这种软件的名称,我可以从模拟输入中获取实时值?
提前非常感谢!
答案 0 :(得分:1)
我认为从模拟引脚读取输入并在Serial monitor上打印就可以了。
以下是我从您可能想要使用的arduino文档中提取的一个简单代码:
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
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
}
请在此link上找到有关代码的完整详细信息。