2、读取模拟电压 - Read Analog Voltage Reads an analog input and prints the voltage to the Serial Monitor. 读取模拟输入并打印电压值到串口监视器。 This example shows you how to read an analog input on analog pin 0, convert the values from analogRead() into voltage, and print it out to the...
void loop() { // read the input on analog pin 0: int sensorValue =analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } 火...
Serial.println(voltage) 现在,当你打开你在Arduino IDE软件上的串口监视器(可以通过键盘快捷键Ctrl+Shift+M打开),你应该看到一个范围从0.0-5.0的稳定的数据流。随着你转动那个旋钮,这个输入到A0引脚的电压值会随之变化。 /* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and pr...
Serial.println(voltage) 现在,当你打开你在Arduino IDE软件上的串口监视器(可以通过键盘快捷键Ctrl+Shift+M打开),你应该看到一个范围从0.0-5.0的稳定的数据流。随着你转动那个旋钮,这个输入到A0引脚的电压值会随之变化。 /* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and pr...
/*ReadAnalogVoltage 读取模拟电压 Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. OPEN THE SERIAL MONITOR TO VIEW THE OUTPUT >> Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. ...
begin(9600); // 初始化串口通信 } void loop() { sensorValue = analogRead(analogInPin); // 读取模拟输入的值 voltage = sensorValue * (5.0 / 1023.0); // 将模拟输入的值转换为电压值 // 打印输出 Serial.print("sensor = "); Serial.print(sensorValue); Serial.print("\t vol = "); ...
int voltage_value1 = analogRead(A1); 声明一个临时浮点变量用于保持浮temp_val等电压值。将该值乘以 0.00488 得到实际电压差,然后除以电阻值以求出电流。0.00488v是Arduino的ADC可以检测到的最小电压。 intsubraction_value =(voltage_value0 - voltage_value1) ; ...
In Arduino, analog input usually refers to the voltage value from the sensor, buttons, or other analog device through the analog pins of Arduino. There are multiple simulation pins on the Arduino board (usually marked as A0-A5), which can be used to read analog signals.以下是一个简单的...
BareMinimum - 需要开始一个新的程序的最简框架 Blink - 使LED灯开和关 DigitalReadSerial - 读取一个开关,打印其状态到Arduino串口监视器 Fade - 示范怎么用模拟输出来使LED灯的亮度变淡 ReadAnalogVoltage - 读取一个模拟输入,并打印电压值到串口监视器...
DigitalReadSerial- 读取一个按键, 并把它的状态输出到 Arduino 串口窗口 Fade- 示范使用模拟输出使 LED 变暗. ReadAnalogVoltage- 读取模拟输入,并把电压输出到 Arduino 串口窗口 翻译:硬创联盟翻译组翻译员 – Lepton-华 审核:硬创联盟翻译组技术审核 - 神奇海螺 返回主目录...