Potentiometer CN: 두 판 사이의 차이

아두위키 : Arduwiki
(새 문서: center|class=coders100 This device can vary its resistance. It can be used to adjust the volume or the brightness of a light. == '''Required Hardware''' == * Variable resistor (B10K used in this text) * Arduino UNO * UNO Cable * Breadboard * M-M Cable (3 pieces) == '''Connection''' == * Power is applied to the left and right, with the output coming from the middle. * Power is applied to either the left or right, with the opposite terminal con...)
 
잔글편집 요약 없음
 
(같은 사용자의 중간 판 2개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{#seo:|title=Arduino维基:Arduino电位器(可变电阻)指南|title_mode=append|keywords=Arduino, 信息科学, 创客学习, 性能评估, 电位器(可变电阻), Arduino项目, 毕业设计项目, Arduino示例代码|description=介绍如何使用Arduino控制电位器(可变电阻)(基本信息、电路、示例代码)。可用于信息科学和创客课程。}}
[[File:가변저항b10k.jpg|center|class=coders100]]
[[File:가변저항b10k.jpg|center|class=coders100]]




This device can vary its resistance.
这个设备可以改变其电阻。
它可以用来调节音量或灯光的亮度。


It can be used to adjust the volume or the brightness of a light.


== '''Required Hardware''' ==
== '''所需硬件''' ==
 
* 可变电阻器(本文中使用B10K)
* Variable resistor (B10K used in this text)
* Arduino UNO
* Arduino UNO
* UNO Cable
* UNO电缆
* Breadboard
* 面包板
* M-M Cable (3 pieces)
* M-M电缆(3根)
 
== '''Connection''' ==


* Power is applied to the left and right, with the output coming from the middle.
* Power is applied to either the left or right, with the opposite terminal connected to GND.
* Connecting as described, turning to the right increases the value, but if connected oppositely (right to GND, left to 5V), turning to the left increases the value.


== '''连接''' ==
* 电源连接到左右两端,输出从中间获得。
* 电源连接到左边或右边,另一端连接到GND。
* 按照描述连接,向右转动会增加值,但如果反向连接(右端接GND,左端接5V),向左转动会增加值。
{| class="wikitable"
{| class="wikitable"
|+
|+
!Variable Resistor
!可变电阻器
!Arduino UNO
!Arduino UNO
|-
|-
36번째 줄: 35번째 줄:
[[File:가변저항 회로.png|center|class=coders100]]
[[File:가변저항 회로.png|center|class=coders100]]


== '''Example Code''' ==
== '''示例代码''' ==
<syntaxhighlight lang="c++">
<syntaxhighlight lang="c++">
#define input A0
#define input A0
42번째 줄: 41번째 줄:
void setup()
void setup()
{
{
   // Start serial communication
   // 开始串行通信
   Serial.begin(9600);
   Serial.begin(9600);
   Serial.println("start");
   Serial.println("start");
50번째 줄: 49번째 줄:
void loop()
void loop()
{
{
   // Display the value of the variable resistor on the serial monitor
   // 在串行监视器上显示可变电阻器的值
   Serial.println(analogRead(input));
   Serial.println(analogRead(input));
   delay(1000);
   delay(1000);

2025년 3월 20일 (목) 19:50 기준 최신판


这个设备可以改变其电阻。 它可以用来调节音量或灯光的亮度。


所需硬件

  • 可变电阻器(本文中使用B10K)
  • Arduino UNO
  • UNO电缆
  • 面包板
  • M-M电缆(3根)


连接

  • 电源连接到左右两端,输出从中间获得。
  • 电源连接到左边或右边,另一端连接到GND。
  • 按照描述连接,向右转动会增加值,但如果反向连接(右端接GND,左端接5V),向左转动会增加值。
可变电阻器 Arduino UNO
Left GND
Middle A0
Right 5V

示例代码

#define input A0

void setup()
{
  // 开始串行通信
  Serial.begin(9600);
  Serial.println("start");
  Serial.println("======================");
}

void loop()
{
  // 在串行监视器上显示可变电阻器的值
  Serial.println(analogRead(input));
  delay(1000);
}