Friday, February 10, 2023

Kicad Footprint Library for PS4 Joystick



 

I made a Kicad footprint for PS4 joysticks and an accompanying breakout board PCB. 

Download here: https://github.com/little-scale/PS4_joystick_footprint 






Code example - prints the X, Y and button values to the serial monitor


const int button = 24;
const int x = A11;
const int y = A12;

int button_current;
int button_previous;

int x_current;
int y_current;
int x_previous;
int y_previous;

void setup() {
Serial.println(57600);
analogReadResolution(8);
analogReadAveraging(100);
pinMode(button, INPUT_PULLUP);

}

void loop() {
button_current = digitalRead(button);
x_current = analogRead(A11);
y_current = analogRead(A12);

if(button_current != button_previous) {
button_previous = button_current;
Serial.print("button: ");
Serial.println(button);
delay(5);
}

if(x_current != x_previous) {
x_previous = x_current;
Serial.print("x: ");
Serial.println(x_current);
delay(5);
}

if(y_current != y_previous) {
Serial.print("y: ");
y_previous = y_current;
Serial.println(y_current);
delay(5);
}
}

1 comment: