Skip to product information
1 of 6

Lonten Tech

Custom Electronic building blocks Dual PS2 game joystick button module JoyStick compatible with For UNO R3

Custom Electronic building blocks Dual PS2 game joystick button module JoyStick compatible with For UNO R3

Regular price $2.21 USD
Regular price $6.21 USD Sale price $2.21 USD
Sale Sold out

Electronic building blocks Dual PS2 game joystick button module JoyStick compatible with  R3

Thanks to the selfless sharing of the user Phoenix, the following test code is written for him, suitable for testing a variety of rocker or button code. Does not differentiate the board. IDE board with 1.8.6. If the latest update is not tested)

 

//This code is provided by phoenix.
// Only joysticks and buttons on all interfaces are tested.
//Only test the rocker and buttons on all interfaces.

void setup(void)
{
Serial.begin(9600); // Set the serial port communication rate to 9600 baud
for ( int i = 0;  i<=13;  i++)// Define the button position
{
pinMode(i,INPUT_PULLUP);
digitalWrite(i, 1);
}
}

void loop(void)
{
//******************* joystick position judgment, from port to port from 0-13; A1-A5(14-20)
for ( int i = 0;  i<=20;  i++)// From ports 0 to 20
{
Serial.print(i);
Serial.print("=");
Serial.print(analogRead(i)); // Read the value of rocker X axis, serial port display
Serial.print(";" );
}
/ / * * * * * * * * * * * * * * * * * * * * * * * * * * * * Button position judgment, from port 0-13,; A1-A5(14-20)
int i, someInt, flag = 0;
for (i = 0;  i<=20;  i++) // From ports 0 to 20
{
if (digitalRead(i) == 0) // Read the status of the button and determine whether to press it
{
Serial.print("button=");
Serial.print(i);
Serial.print(";" );
}
}
Serial.println(""); // End a line

delay(100);    // Refresh once 100ms
}

View full details