@@ -25,6 +25,7 @@ PS4BT PS4(&Btd, PAIR);
25
25
// PS4BT PS4(&Btd);
26
26
27
27
boolean printAngle, printTouch;
28
+ uint8_t oldL2Value, oldR2Value;
28
29
29
30
void setup () {
30
31
Serial.begin (115200 );
@@ -56,28 +57,46 @@ void loop() {
56
57
Serial.print (F (" \t R2: " ));
57
58
Serial.print (PS4.getAnalogButton (R2));
58
59
}
60
+ if (PS4.getAnalogButton (L2) != oldL2Value || PS4.getAnalogButton (R2) != oldR2Value) // Only write value if it's different
61
+ PS4.setRumbleOn (PS4.getAnalogButton (L2), PS4.getAnalogButton (R2));
62
+ oldL2Value = PS4.getAnalogButton (L2);
63
+ oldR2Value = PS4.getAnalogButton (R2);
64
+
59
65
if (PS4.getButtonClick (PS)) {
60
66
Serial.print (F (" \r\n PS" ));
61
67
PS4.disconnect ();
62
68
}
63
69
else {
64
- if (PS4.getButtonClick (TRIANGLE))
70
+ if (PS4.getButtonClick (TRIANGLE)) {
65
71
Serial.print (F (" \r\n Traingle" ));
66
- if (PS4.getButtonClick (CIRCLE))
72
+ PS4.setRumbleOn (RumbleLow);
73
+ }
74
+ if (PS4.getButtonClick (CIRCLE)) {
67
75
Serial.print (F (" \r\n Circle" ));
68
- if (PS4.getButtonClick (CROSS))
76
+ PS4.setRumbleOn (RumbleHigh);
77
+ }
78
+ if (PS4.getButtonClick (CROSS)) {
69
79
Serial.print (F (" \r\n Cross" ));
70
- if (PS4.getButtonClick (SQUARE))
80
+ PS4.setLedFlash (10 , 10 ); // Set it to blink rapidly
81
+ }
82
+ if (PS4.getButtonClick (SQUARE)) {
71
83
Serial.print (F (" \r\n Square" ));
84
+ PS4.setLedFlash (0 , 0 ); // Turn off blinking
85
+ }
72
86
73
- if (PS4.getButtonClick (UP))
87
+ if (PS4.getButtonClick (UP)) {
74
88
Serial.print (F (" \r\n Up" ));
75
- if (PS4.getButtonClick (RIGHT))
89
+ PS4.setLed (Red);
90
+ } if (PS4.getButtonClick (RIGHT)) {
76
91
Serial.print (F (" \r\n Right" ));
77
- if (PS4.getButtonClick (DOWN))
92
+ PS4.setLed (Blue);
93
+ } if (PS4.getButtonClick (DOWN)) {
78
94
Serial.print (F (" \r\n Down" ));
79
- if (PS4.getButtonClick (LEFT))
95
+ PS4.setLed (Yellow);
96
+ } if (PS4.getButtonClick (LEFT)) {
80
97
Serial.print (F (" \r\n Left" ));
98
+ PS4.setLed (Green);
99
+ }
81
100
82
101
if (PS4.getButtonClick (L1))
83
102
Serial.print (F (" \r\n L1" ));
0 commit comments