So I just tried to post this on the project hub, added all the parts and tools, even helpful little comments on everything that I could. Then when I added the diagram, everything disappeared. So it’s going here.
The main reason I did this is so I can fly my racing drone the same way I fly a helicopter in GTA5. My FPV cam is mounted on a single axis gimbal(up/down). In the game, the left stick controls pitch and roll, the right stick controls the camera. Yaw is done with bumpers but i’m just going to use the right stick X-axis for yaw. To gain altitude, you pull the right trigger(accelerator). To go down, you pull the left trigger. To maintain altitude, you simply let go of both triggers.
With this sketch, you are able to set the mid-throttle by holding
R1 R2 and L1, then pulling the throttle to the desired position and releasing R1 L1. R1 temporarily holds the mid throttle at 0 so it doesn’t jump when you release L1. If you don’t hold R2(Brake), the throttle will jump as soon as you release L1.
To set it to center(50/50),
hold square and tap R1 click SHARE and OPTIONS together. This is useful for using with RC cars with brake/reverse where you need the controller to be 50/50.
I attached the diagram to wire the 6 digipots(MCP4151-103). The three rows of holes at the top are for the potentiometer connections.
Note the MCP4151 does not require any external circuitry(diodes, resistors…), just make the connections.
I wanted to power the arduino from the same battery as the controller(Frsky Taranis Q-X7), if you want to do this too, you will probably want to use a voltage regulator or boost converter just to be safe.
I will upload pictures once i figure out how to get them off of my phone.
The sketch says that you only have to pair the PS4 controller once but i have to re pair every time I power on the arduino.
I will probably be adding more features to this as i use it more and more. If you have any suggestions, please share your ideas.
Commenting out all of the serial crap saves something like 10% of the program space.
Failsafe is the last else() loop at the end of the sketch.
added LED color change effects as throttle increases.
added gyroscope raw value feedback. The gyroscope does not put out an actual angle, instead it puts out the angle it has traveled over an amount of time(I think it has to do with refresh rate) so the number goes up(to around 40000 at its fastest rate) the faster you move it and adds it(scaled down from 0-10,000 to 0-50 because you would have to pull pretty fast and hard to get it to go much higher than 10,000) to the pitch(tilt back and forth) and yaw(tilt side to side on controller yaws/turns the vehicle.
CAUTION: THE GYRO FEEDBACK FEATURE IS COMPLETELY UNTESTED OTHER THAN COMMUNICATION BETWEEN THE CONTROLLERS. I’VE NEVER SEEN ANYTHING LIKE THIS OTHER THEN IN VIDEO GAMES(LEAN TO TURN MORE) SO BE EXTRA CAUTIOUS WHEN EXPERIMENTING WITH THIS FEATURE ]
Failsafe goes to 128 if prehover = 128(square + L1)(LED flashes blue and yellow for 128 only) and 0 if its anything else.
Hold R3(click and hold right stick) to flash battery level(2 sec on, 2 sec off=don’t worry;1 sec on, 1 sec off=above 30ish%;half sec on, half sec off=watch out; 1/10 sec on, 1/10 sec off= bring it in, shut it down).
Added some comments.
I think that’s it for now. Please ask questions or at least say something so I know someone is interested.