Files
esp8266_study/代码案例/6 Arduino基础学习/29 模拟输入2 – analogRead/analogRead/analogRead.ino
2024-09-27 01:22:07 +08:00

31 lines
742 B
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
模拟输入
本程序旨在演示如何使用analogRead()读取Arduino的引脚电平。
通过调节电位器, A0引脚的输入电压将在0V5V之间。
该输入电压将被映射到数值0-1023之间并显示在串口监视器中。
电路连接:
电位器中间引脚连接到模拟输入A0引脚
电位器两端引脚分别连接在Arduino +5V和接地引脚
太极创客 www.taichi-maker.com
2017-01-08
This example code is in the public domain.
*/
void setup() {
// 串口通讯初始化(9600 bps):
Serial.begin(9600);
}
void loop() {
// 读取模拟输入值:
int analogInputVal = analogRead(A0);
// 将结果通过串口监视器显示:
Serial.println(analogInputVal);
}