Arduino教程(3)电路基础知识


//Reads the State of a Pot and displays on screen

int potPin = 0; 电位器接在模拟引脚0上,将其赋予potPin变量方便以后引用

void setup()
{
//sets the button pin as an input
pinMode(potPin, INPUT); 将potPin设为输入

//Allows us to listen to serial...详情
//Reads the State of a Pot and displays on screen

int potPin = 0; 电位器接在模拟引脚0上,将其赋予potPin变量方便以后引用

void setup()
{
//sets the button pin as an input
pinMode(potPin, INPUT); 将potPin设为输入

//Allows us to listen to serial communications from the arduino
Serial.begin(9600); 将串口通讯速率设为9600
}

void loop()
{
// print the button state to a serial terminal
Serial.println(analogRead(potPin)); 将从potPin读入数据打印到串口监控窗口
delay(1000); 等待1000ms
//wait one second, then print again.
}

电位器 (英文:Potentiometer)是可变电阻器的一种。通常是由电阻体与转动或滑动系统组成,即靠一个动触点在电阻体上移动,获得部分电压输出。隐藏

标签: arduino视频