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. https://www.arduino.cc/en/Tutorial/BuiltInExamples/ReadAnalogVolta...
By Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/AnalogInput */ int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming ...
This example code is in the public domain. */ // These constants won't change. They're used to give names // to the pins used: const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Analog output pin that the LED ...
The parameters of the function of the function include:The minimum input (in this example is 0),The input maximum value (in this example 1023),The minimum output (in this example 0),The output maximum value (in this example is 100).最后,我们使用`Serial.print()`函数将转换后的值打印到...
This example code is in the public domain.此代码示例位于公共域中。arduino.cc/en/Tutorial/...int sensorPin = A0; // select the input pin for the potentiometer 选择电位器的输入针脚 int ledPin = 13; // select the pin for the LED 选择 LED 针脚 int sensorValue = 0; // ...
① 模拟输入引脚是带有ADC(Analog-to-Digital Converter,模数转换器)功能的引脚。 ②它可以将外部输入的模拟信号转换为芯片运算时可以识别的数字信号,从而实现读入模拟值的功能。 ③模拟输入功能需要使用analogRead() 函数。 参数:参数pin是指定要读取模拟值的引脚,被指定的引脚必须是模拟输入引脚。如analogRead(A0),即...
This example code is in the public domain.*/intsensorValue =0;intoutputValue =0;voidsetup() { pinMode(A0, INPUT); pinMode(9, OUTPUT); Serial.begin(9600); }voidloop() {//read the analog in value:sensorValue =analogRead(A0);//map it to the range of the analog out:outputValue =...
This example code is in the public domain.*/intsensorValue =0;voidsetup() { pinMode(A0, INPUT); Serial.begin(9600); }voidloop() {//read the input on analog pin 0:sensorValue =analogRead(A0);//print out the value you read:Serial.println(sensorValue); ...
2、模拟输入 - Analog Input In this example we use a variableresistor(a potentiometer or a photoresistor), we read its value using one analog input of an Arduino board and we change the blink rate of the built-in LED accordingly. The resistor's analog value is read as a voltage because ...
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...