
Description Function Coding Example
Return Button Group Byte Value
Returns the binary byte value of a PS4
button group.
The Tele-Op module can return
the digital status of two button
groups represented as a binary byte.
The digital status of each button
in the group is indicated by its
corresponding binary digit position in
the byte.
Button Group 1 (buttons_1):
L1, L2, R1, R2, CROSS, CIRCLE,
SQUARE, TRIANGE
Button Group 2 (buttons_2):
L3, R3, UP, DOWN, RIGHT, LEFT, SHARE,
OPTIONS
ps4.buttons_1;
or
ps4.buttons_2;
Data Returned: Byte
void loop() {
ps4.getPS4();
byte group1 = ps4.buttons_1;
byte group2 = ps4.buttons_2;
}
group1 = the byte value of the
buttons_1 group
group2 = the byte value of the
buttons_2 group
Tip: Use the Serial Monitor statement
with the BIN format parameter to
see the binary value of each button
group’s status.
Serial.println(ps4.buttons_1, BIN);
or
Serial.println(ps4.buttons_2, BIN);
Read Touch Pad
Returns the x- or y-coordinate of
the finger position touched and
moved across the surface of the PS4
controller touch pad.
ps4.Touchpad(TOUCHX);
or
ps4.Touchpad(TOUCHY);
Data Returned: Integer
void loop() {
ps4.getPS4();
int x = ps4.Touchpad(TOUCHX);
int y = ps4.Touchpad(TOUCHY);
}
x= the x-coordinate of PS4 touch pad
y= the y-coordinate of PS4 touch pad
Read Position of Data Mapped to
Motor
Returns the position of a PS4
controller’s left and right joystick axis,
analog trigger buttons, or pitch and
roll gyro data mapped to a motor
power and direction range of -100 to
100.
Motor function mapping parameters
are:
LX, LY, RX, RY, L2T, R2T, PITCH, ROLL
ps4.Motor(LX);
Data Returned: Integer
Range: -100 to 100
void loop() {
ps4.getPS4();
int x = ps4.Motor(LX);
}
x= the position of the left x-axis
joystick mapped to a motor power and
direction range of -100 to 100
Tip: Replace LX with the parameter
mapped to a motor power and
direction range that you wish to
return.
Read Position of Data Mapped to
Servo
Returns the position of a PS4
controller’s left and right joystick
axis, analog trigger buttons, or pitch
and roll gyro data mapped to a servo
motor position range of 0 to 180
degrees.
Servo function mapping parameters
are:
LX, LY, RX, RY, L2T, R2T, PITCH, ROLL
ps4.Servo(RY);
Data Returned: Integer
Range: 0-180
void loop() {
ps4.getPS4();
int y = ps4.Servo(RY);
}
y= the position of the right y-axis
joystick mapped to a servo motor
position range of 0 to 180 degrees
Tip: Replace RY with the parameter
mapped to a servo motor position
range that you wish to return.
76543210Bits
Byte
Group 1:
Bit 0: L2
Bit 1: L1
Bit 2: R2
Bit 3: R1
Bit 4: CROSS
Bit 5: CIRCLE
Bit 6: SQUARE
Bit 7: TRIANGLE
Group 2:
Bit 0: UP
Bit 1: DOWN
Bit 2: RIGHT
Bit 3: LEFT
Bit 4: R3
Bit 5: L3
Bit 6: SHARE
Bit 7: OPTIONS