คำอธิบาย
ตัวแปลงจอยสติ๊กไร้สาย Arduino PS2 Wireless Joystick Converter SPI-01
Product Parameters
- Working voltage DC3.3V – 5V
- Working current 10mA
- Data refers PS2 interface 6pin
Pinout
- CLK
- CS
- CMD
- DAT
- +VCC/VDD
- GND
ตัวอย่างโค้ดอาดูโน่ต่อกับ joystick PS2 ผ่าน spi
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 32 33 34 35 36 |
#include <PS2X_lib.h> // Pin definitions for PS2 controller #define PS2_CLK 11 #define PS2_CMD 10 #define PS2_ATT 9 #define PS2_DAT 8 PS2X ps2x; // PS2 controller object void setup() { // Initialize serial communication Serial.begin(9600); // Initialize the PS2 controller ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_ATT, PS2_DAT); } void loop() { // Check if there's data available from the PS2 controller if (ps2x.read_gamepad()) { // Print the values of the buttons and joystick axes Serial.print("Button L1: "); Serial.println(ps2x.Button(PSB_L1)); Serial.print("Button R1: "); Serial.println(ps2x.Button(PSB_R1)); Serial.print("Button L2: "); Serial.println(ps2x.Button(PSB_L2)); Serial.print("Button R2: "); Serial.println(ps2x.Button(PSB_R2)); Serial.print("Analog Stick Left-Right: "); Serial.println(ps2x.Analog(PSS_LX)); Serial.print("Analog Stick Up-Down: "); Serial.println(ps2x.Analog(PSS_LY)); } } |
รีวิว
ยังไม่มีบทวิจารณ์