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. This example code is in the public domain. */ 功能:读取模拟输入引脚A0的值,并将其打印到串行监视器。 硬件连接:将电位...
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...
This example shows you how to read analog input from the physical world using a potentiometer. Apotentiometeris a simple mechanical device that provides a varying amount of resistance when its shaft is turned. By passing voltage through a potentiometer and into an analog input on your board, it...
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 ...
// 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); } [Get Code] 更多 setup() loop()
int val = 0; // variable to store the read value void setup() { pinMode(ledPin, OUTPUT); // sets the pin as output } void loop() { val = analogRead(analogPin); // read the input pin analogWrite(ledPin, val / 4); }
int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); ...
由于每个BSP的板子设计、以及芯片型号等,引脚分布是有区别的,因此需要到指定BSP的applications/arduino文件夹下的README.md文件查看详细信息。例如: STM32L475潘多拉板的Arduino引脚布局的详细说明 | STM32F072 Nucleo板的Arduino引脚布局的详细说明 3 Arduino库的导入和使用 ...
演示模拟输入,通过读取连接到模拟针脚 0 的模拟传感器,控制连接到数字针脚 13 上的 LED 的点亮和熄灭。LED 点亮和熄灭的时长由 anlogRead() 读取的数值控制。The circuit:电路连接 - potentiometer 电位器 center pin of the potentiometer to the analog input 0 one side pin (either one) to ...
// put your setup code here, to run once: pinMode(13, OUTPUT); Serial.begin(9600); } void loop() { char ch; if(Serial.available()){ ch = Serial.read(); flashDashDot(MorseTable[ch]); delay(dotLength*2); } } void flashDashDot(const char * morseCode) ...