Using PS3 Controlle...
 
Notifications
Clear all

Using PS3 Controllers with ESP32 | Build Custom Remote Controls

91 Posts
11 Users
9 Likes
6,508 Views
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1053
Topic starter  

Control the world (or anything you can hook up to an ESP32) using a PS3 controller! I’ll show you how to control motors, LEDs, and more.

If you’re looking for an easy to use and yet sophisticated remote control for your next ESP32 project, why not try a PS3 controller? Priced at around 10 dollars on Amazon, these little gems feature many controls and features, including an accelerometer, two joysticks, and a rechargeable battery.

I’ll show you how to use the ESP32-PS3 Library to simplify interfacing with the controller. This amazing library covers every controller event and even lets you “rumble” the controllers' motors!

I’ll also show you my “robot car experimenters platform,” which is a long-winded way of saying a two-wheeled car base with a power supply, motor driver, and solderless breadboard. I’ll use it to demonstrate control of some LEDs and motors. You'll see how easy it is to adapt the library to your own special needs.

When we are done, we’ll have the basis of a robot car controlled by a PS3 remote control!

Here is the Table of Contents of today's video:

00:00 - Introduction
01:29 - PS3 Controllers
07:03 - Controller MAC Address
09:02 - ESP32-PS3 Library
10:53 - ESP32-PS3 Library - PS3Demo
16:22 - ESP32-PS3 Library - PS3Accelerrometer
17:46 - ESP32-PS3 Library - PS3Rumble
20:04 - My Robot Car Test Base
26:01 - Controlling LEDs
33:39 - Controlling an RGB LED
40:35 - Controlling a Servo Motor
46:34 - Responding to TOF Sensor
52:52 - Controlling DC Motors
1:02:46 - Final Robot Car Code & Demo
1:06:03 - Conclusion

You may have a few of these remote controls kicking around the house, dust them off and use them as unique remote controls!

Hope you enjoy the video.

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
Quote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@dronebot-workshop

On page 9 of the PDF accompanying article there is this statement: "With the controller connected, just run the Sixaxis Pair Tool. The MAC address of the console should be displayed."  Should that not say "controller" instead of "console?"  Or am I lost and confused.  Wouldn't be the first time, and doubt it will be the last!

SteveG


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@dronebot-workshop I see in the video the notify procedure has a bunch of if's, isn't that the least efficient way to code that? At least use if x==1; elseif y==2; etc and even better probably a case statement. One exception to that is if multiple events are pending which appears to be possible but there are at least 2 ways to deal with that, one is loop in notify to clear all events, or do one and exit back to the main loop. If there were a lot of events the method shown ties up the device clearing them all inside notify. I understand for this application it is not critical, but maybe the next application is and learning these techniques from the start is good practice.

OR

Maybe this old man is losing more than his hair.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@zander 

It all comes down to some personal preferences in my book.  I've known a good number of programmers that never use the "else" statement.  Using it can sometimes lead to confusion later on when someone else is trying to understand what is going on.

I used to use "else" quite often, but now find myself writing more code without it.

SteveG


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

My SixAccessPairTool always shows "no device found..."  It did one time show something about loading drivers when I had the app running and then plugged in a game controller.  But even though it gave a message that loading the driver could take up to 5 minutes, after just a few seconds that message and the loading progress bar went away.  Never even saw an update on the progress bar.

I'm running an updated Windows 10.  Any ideas?

SteveG


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@codecage I am not talking about personal preference, I am talking about testing say 20 if's and only one is true as opposed to a case going direct to the code wanted and in an elif situation exiting once a true if is encountered. In the case of elif, they can be prioritized.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
John_B
(@john_b)
Member
Joined: 3 years ago
Posts: 18
 

Posted by: @codecage

My SixAccessPairTool always shows "no device found..." ........

So does mine. I've also tried pairing it with a controller tester app on my phone, and my Raspberry Pi 400 doesn't find it. It flashes some red lights for a short time, but shows no other sign of life. Is this when it's trying to pair? I've never even seen one of these controllers before, as the only gaming I do is play Solitaire, which only needs a mouse! So I've no idea if it's working but I don't know how to use it, or if it's faulty. I've charged the battery.

This is the one I bought https://www.ebay.co.uk/itm/194097177125?var=494229268973 .

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@john_b Some bluetooth devices are near impossible to connect. I had a device so finicky that the manufacturer was starting the return procedure ( this was a multi hundred dollar device) when we tried a different phone and then it worked and has been ever since.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
John_B
(@john_b)
Member
Joined: 3 years ago
Posts: 18
 

A bit of progress! In the article Bill said "You’ll need to connect the PS3 controller to your Windows computer using a USB cable; one probably came with the controller ". Mine did come with a cable, but it seems to be  power only, not data! With a data cable, Sixaxis Pair Tool connected straight away. My MAC address is 00:12:34:56:78:9b, so other clones may well have the same address.

At least I know the thing is alive, but I'm surprised it doesn't have a charge indicator LED, so wonder if it is faulty. I'll try it with an ESP32 when I get a chance.


   
codecage reacted
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1053
Topic starter  

@john_b Just a thought - the two controllers that I purchased came with a MAC Address of 00:00:00:00:00:00, which makes sense as it's the Broadcast address. Perhaps your new controller was also set that way.

Although it looked strange, I had no problem running the controller using 00:00:00:00:00:00 as the Mac address in the ESP32 sketches.

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
AlanL
(@alanl)
Member
Joined: 3 years ago
Posts: 34
 

Could you tell me the make of your PS3 controller, I have had to return 2 controllers, 1 from Amazon and 1 from Ebay. Neither controllers connected to SixAxis Pair Tool .

6AxisTool

 


   
ReplyQuote
AlanL
(@alanl)
Member
Joined: 3 years ago
Posts: 34
 

Forgot to tick subscribe to this topic


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@alanl 

I think @john_b has just given us a hint at what our issue is with the "No device found..." message.  The cables that come with the controllers are power ONLY!  Makes sense as this is normally the only real need for the cable.  I'm going to dig thru my stash of USB cables and try some that I know are data cables as well as power.  And if that is my issue as well, then the included cables are destined for the trash can! 

SteveG


   
ReplyQuote
AlanL
(@alanl)
Member
Joined: 3 years ago
Posts: 34
 

I have used my Arduino cable that loads code as well as the one supplied and neither work!


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@john_b 

My two controllers when first turned on show all four LEDs lit up, then go out after a a short while.  My take is that the 4 LEDs show the battery as fully charged and then after giving up trying to pair with a console all LEDs turn off.  When connected to my laptop with the supplied (maybe power only) cable the only LEDs 1 & 4 come on.  Maybe that is the charge indication?

Off to find USB cables that include data as well.

SteveG


   
ReplyQuote
Page 1 / 7