如题,老师给了10kΩ旋转变阻器,LCD,220Ω电阻,Arduino Uno。要求是能测量出旋转变阻器的旋转角度到LCD上。
请问旋转变阻器和旋转角度是成正比的吗,电阻要接到哪里,下面那个code是用旋转变阻器测角度,但是用了别的元件如图所示,该怎么改啊,求教一下旋转电阻测量角度的code怎么写,ADC_REF是什么? 非常感谢🙏
#define ROTARY_ANGLE_SENSOR A0
#defineВ ADC_REFВ 3.3
#define FULL_ANGLEВ 300.0
void setup()
{
Serial.begin(9600);
}
void loop()
{
int degrees = getDegrees();
//Output it to the serial monitor
Serial.print("The angle between the mark and the start position: ");
Serial.println(degrees);
delay(500);
}
int getDegrees()
{
int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
float voltage = (float)sensor_value * ADC_REF / 1023;
float degrees = (voltage * FULL_ANGLE) / ADC_REF;
return degrees;
}
请问旋转变阻器和旋转角度是成正比的吗,电阻要接到哪里,下面那个code是用旋转变阻器测角度,但是用了别的元件如图所示,该怎么改啊,求教一下旋转电阻测量角度的code怎么写,ADC_REF是什么? 非常感谢🙏
#define ROTARY_ANGLE_SENSOR A0
#defineВ ADC_REFВ 3.3
#define FULL_ANGLEВ 300.0
void setup()
{
Serial.begin(9600);
}
void loop()
{
int degrees = getDegrees();
//Output it to the serial monitor
Serial.print("The angle between the mark and the start position: ");
Serial.println(degrees);
delay(500);
}
int getDegrees()
{
int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
float voltage = (float)sensor_value * ADC_REF / 1023;
float degrees = (voltage * FULL_ANGLE) / ADC_REF;
return degrees;
}