Devices & Components
PS5 Controller
ESP 32
Jumper Male to Female 20 cm
Pack of 50 female-female jumper wires in various colors
Car Kit
Hardware & Tools
Solder Soldering Wire
Solder Flux, Rosin
Soldering Station
drill, screwdriver, soldering iron
Software & Tools
Arduino IDE
Project description
Code
esp code
cpp
code
1#include <ps5Controller.h> 2 3 4 5void setup() { 6 7 Serial.begin(921600); 8 9 pinMode(16,OUTPUT); 10 11 pinMode(17,OUTPUT); 12 13 pinMode(18,OUTPUT); 14 15 pinMode(19,OUTPUT); 16 17 pinMode(22,OUTPUT); 18 19 pinMode(23,OUTPUT); 20 21 ps5.begin("1a:2b:3c:01:01:01"); //replace with MAC address of your controller 22 23 Serial.println("Ready."); 24 25 digitalWrite(22,HIGH); 26 27 digitalWrite(23,HIGH); 28 29} 30 31 32 33void loop() { 34 35// while (ps5.isConnected() == false) { // commented out as ps5 controller seems to connect quicker when microcontroller is doing nothing 36 37// Serial.println("PS5 controller not found"); 38 39// delay(300); 40 41// } 42 43 44 45 while (ps5.isConnected() == true) { 46 47 if (ps5.Right()) Serial.println("Right Button"); 48 49 if (ps5.Down()) Serial.println("Down Button"); 50 51 if (ps5.Up()) Serial.println("Up Button"); 52 53 if (ps5.Left()) Serial.println("Left Button"); 54 55 56 57 if (ps5.Square()) Serial.println("Square Button"); 58 59 if (ps5.Cross()) Serial.println("Cross Button"); 60 61 if (ps5.Circle()) Serial.println("Circle Button"); 62 63 if (ps5.Triangle()) Serial.println("Triangle Button"); 64 65 66 67 if (ps5.UpRight()) Serial.println("Up Right"); 68 69 if (ps5.DownRight()) Serial.println("Down Right"); 70 71 if (ps5.UpLeft()) Serial.println("Up Left"); 72 73 if (ps5.DownLeft()) Serial.println("Down Left"); 74 75 76 77 if (ps5.L1()) Serial.println("L1 Button"); 78 79 if (ps5.R1()) Serial.println("R1 Button"); 80 81 82 83 if (ps5.Share()) Serial.println("Share Button"); 84 85 if (ps5.Options()) Serial.println("Options Button"); 86 87 if (ps5.L3()) Serial.println("L3 Button"); 88 89 if (ps5.R3()) Serial.println("R3 Button"); 90 91 92 93 if (ps5.PSButton()) Serial.println("PS Button"); 94 95 if (ps5.Touchpad()) Serial.println("Touch Pad Button"); 96 97 98 99 if (ps5.L2()) { 100 101 Serial.printf("L2 button at %d\n", ps5.L2Value()); 102 103 } 104 105 if (ps5.R2()) { 106 107 Serial.printf("R2 button at %d\n", ps5.R2Value()); 108 109 } 110 111 112 113 if (ps5.LStickX()) { 114 115 Serial.printf("Left Stick x at %d\n", ps5.LStickX()); 116 117 118 } 119 120 if (ps5.LStickY()) { 121 122 Serial.printf("Left Stick y at %d\n", ps5.LStickY()); 123 124 if(ps5.LStickY()>100){ 125 126 digitalWrite(16,HIGH); 127 128 digitalWrite(17,LOW); 129 130 } 131 132 else{ 133 134 digitalWrite(17,LOW); 135 136 digitalWrite(16,LOW); 137 138 } 139 140 } 141 142 if(ps5.LStickY()<20){ 143 144 digitalWrite(17,HIGH); 145 146 digitalWrite(16,LOW); 147 148 } 149 150 else{ 151 152 digitalWrite(16,LOW); 153 154 digitalWrite(17,LOW); 155 156 } 157 158 } 159 160 if (ps5.RStickX()) { 161 162 Serial.printf("Right Stick x at %d\n", ps5.RStickX()); 163 164 } 165 166 if (ps5.RStickY()) { 167 168 Serial.printf("Right Stick y at %d\n", ps5.RStickY()); 169 170 if(ps5.RStickY()>100){ 171 172 digitalWrite(18,HIGH); 173 174 digitalWrite(19,LOW); 175 176 } 177 178 else{ 179 180 digitalWrite(19,LOW); 181 182 digitalWrite(18,LOW); 183 184 } 185 186 if(ps5.RStickY()<20){ 187 188 digitalWrite(19,HIGH); 189 190 digitalWrite(18,LOW); 191 192 } 193 194 else{ 195 196 digitalWrite(19,LOW); 197 198 digitalWrite(18,LOW); 199 200 } 201 202 } 203 204 205 206 Serial.println(); 207 208 // This delay is to make the output more human readable 209 210 // Remove it when you're not trying to see the output 211 212 //delay(300); 213 214 }
Downloadable files
libraries
noon
https://github.com/rodneybakiskan/ps5-esp32
Documentation
for query vist my instructable page https://www.instructables.com/ESP-32-WITH-PS5-CONTROLLER-CAR/
dd
ESP-32-WITH-PS5-CONTROLLER-CAR (2).txt
Comments
Only logged in users can leave comments