介绍
该模块检测操纵杆的X和Y位置,并将其作为输出引脚处的模拟电压输出。每个轴,X和Y都安装了单独的电位器。在空闲状态下,电位计在中间,这意味着电阻和电压相同。
如果更改X或Y轴的位置,则电阻会根据新位置而变化。电阻的这种变化导致电阻值之间可以测量的电压值。这允许确定轴的确切位置。
该模块非常适合在需要精确检测运动的游戏,机器人技术或其他项目中的控制系统等应用程序。通过将位置作为模拟电压输出,可以轻松地将操纵杆集成到各种电子系统中,以提供准确和直观的控制。
| Technical Data | 
 | 
| Operating voltage | 
3,3 V - 5 V | 
| Dimensions | 
19 x 18,5 x 9 mm | 
引脚连接
pin 引脚连接开发板的 gpio 接口即可:
| Arduino | 
Sensor | 
| 5 V | 
+5V | 
| GND | 
GND | 
| Pin A2 | 
VRy | 
| Pin A3 | 
VRx | 
| Pin 5 | 
Button | 
代码示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
   | int joystick_X = A0;  int joystick_Y = A1;  int joystick_button = 3;    void setup () {   pinMode(joystick_button, INPUT);   digitalWrite(joystick_button, HIGH);     Serial.begin (9600);  }
  void loop () {   float temp_x, temp_y;   int button_value;       temp_x = analogRead(joystick_X);    temp_y = analogRead(joystick_Y);   button_value = digitalRead(joystick_button);       Serial.print ("x-axis: ");    Serial.print (temp_x, DEC);     Serial.print ("V, \ty-axis: ");   Serial.print (temp_y, DEC);     Serial.print ("V, \tbutton: ");   if (button_value == 1) {       Serial.println("not pressed");   }   else {       Serial.println("pressed");   }   delay(10); }
   | 
 
小结
待完善…