How to Make PS2 Controller With Arduino and NRF24L01
by dgmark in Circuits > Remote Control
25481 Views, 66 Favorites, 0 Comments
How to Make PS2 Controller With Arduino and NRF24L01
This will be a two part tutorial. The idea is to modify this PS2 controller to control this fpv rc hummer (tutorial coming soon). This is not the first intructable about this topic, so I will also point out where I got some of the information and integrate it with my own steps.
Gathering Materials
1 x Wired PS2 controller (clone)
1 x Arduino nano
1 x NRF24L01+PA+LNA
1 x Socket Adapter Module Board for NRF24L01+ (or you can try to directly power it using the 3.3v of the arduino but put a capacitor to make the voltage smoother)
2 x 16340 Li-ion battery
1 x USB Lithium Battery Charger Module Board
1 x toggle switch
1 x small dc motor (optional)
1 x L293D motor driver (optional, only if you add dc motor for vibration)
Schematic Arduino to NRF24L01+ and PS2
Shematic Power Supply
Note If You Want to Add Motor to Simulate Vibration
If you wanted to add a dc motor, you will need to add a motor driver (example: L293D) as you cannot directly connect it to the pins of the arduino as it requires a lot of current which may harm the arduino. Initially I wanted to add a dc motor but unfortunately my motor driver broke and I was not able to purchase another quickly, so I ditch that part (though as you can see in one of the picture, the dc motor is still there).
If you're interested in adding the motor, here is how to do it.
Putting It Together
I attached the battery in parallel to boost up the amperage, as I'm using a cheap battery and amperage are quite low.
Unfortunately I was not able to fit some of the electronics inside, here you can see that half of the arduino and the nrf24L01+ are sticking outside.
Code for the PS2 Controller
Here is the sample code. I used Visual Studio 2017 Community Edition with Visual Micro as it is much better than the stock Arduino IDE. Anyway before that you will need the following libraries: PS2X and RF24
In the code, you might also found something related to BatteryCheck, currently it is not being used. I initially intended it to check the battery level as I'm using unprotected battery, but I was not able to get it running accurately.
The code itself I admit is very far from optimized, I would appreciate if someone could expand/modify and optimize it and give feedback to benefit others.
Downloads
Here Is Sample of What I Want to Do With It
Soon to Be Added
- add OLED screen
- Make it more compact, no electronic parts will be visible outside
- activate vibration motor
- Try to extend the range more. Currently it can pass only to one wall, and the range is only around 20 meters along the house. I have not tried outside, maybe it can go up to 50 meters.