ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result...
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); } Code...
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...
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...
格瑞图:Arduino-0007-内置示例-读取模拟电压 Read Analog Voltage 格瑞图:Arduino-0008-内置示例-非延迟闪烁 Blink Without Delay 格瑞图:Arduino-0009-内置示例-按钮 Button 格瑞图:Arduino-0010-内置示例-去抖 Debounce 1、示例代码及解析 (1)代码 /*
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...
BareMinimum - 需要开始一个新的程序的最简框架 Blink - 使LED灯开和关 DigitalReadSerial - 读取一个开关,打印其状态到Arduino串口监视器 Fade - 示范怎么用模拟输出来使LED灯的亮度变淡 ReadAnalogVoltage - 读取一个模拟输入,并打印电压值到串口监视器...
and over again forever:voidloop() {// read the input on analog pin 0:intsensorValue =analogRead(A0);// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):floatvoltage = sensorValue * (5.0/1023.0);// print out the value you read:Serial.println(voltage);...
runs over and over again forever:voidloop(){// read the input on analog pin 0:intsensorValue=analogRead(A0);// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):floatvoltage=sensorValue*(5.0/1023.0);// print out the value you read:Serial.println(voltage)...
ReadAnalogVoltage, 该demo中出现float类型的变量,死循环函数可以直接用while(1);,或者while(1){},float类型在arduino语言中,只要有一个变量为小数,即可如,5.2/1023.0或者5.2/1023,或者5./1023等等都可以,经测试输出结果保留小数点后两位。 digital blinkwithoutdelay ...