Joystick Motor Controller issues

UPDATE: I'm just going to revert to what I know works and use a RoboClaw motor controller, thanks for the suggestions.

Hello there! I'm working on a project where I'm using the BluePad32 Library to connect an Arduino Nano RP2040 Connect to a PlayStation4 Controller to control a nerf dart robot I designed and 3D printed.

Have you considered tank steering where one joystick controls one motor? It would simplify things, but if you have a nerf launcher then you are probably using one joystick for drive and the other to move the launcher.

If it is the latter, where one joystick controls the drive then you need to divide the joystick into 5 areas. These 5 areas (center being all off) will determine which motors are active. (In1-In4)

Forward = 0101
Reverse = 1010
Left = 0110
Right = 1001
Center = 0000

(You can add combinations of forward + left etc. but that is more math involved)

Then you will need to determine the speed each motor receives by converting the X and Y axis into cartesian coordinates (-1 to 1) to then use sine and cosine to determine the speed differences.

It would probably be better to just look up “tank drive with single joystick” and adapt that with what you have now.

It looks great and following the forum guideline using code tags helps a lot. I question your choice on the motor driver, that is an old obsolete part that will use at least 3V of your motor voltage as heat. I suggest you get one with MOSFET outputs. Posting an annotated schematic would help a lot. Be sure to show exactly how everything is connected, including all power, ground, and power sources. Links to the component technical data would be a big help.

I am indeed using the left joystick X and Y axis for driving and the right joystick X and Y got servo pan and tilt.

As for Tank steering as I understand it having one motor moving forward and the opposite motor moving backwards spins the tank one direction and then reversing the motor directions spins the tank the opposite direction.

See my previous comment, I edited it.

I have heard that this motor driver is inefficient, I'd thought about using a roboclaw as I have previous experience but I was trying to keep costs down in case I end up making this whole thing open source so it's an affordable project for people.

Would you have any motor controller with examples that you'd recommend (I learn better from examples)? I'd be open to other alternatives for sure I've just ran across so many examples using the L298n that I originally figured it was something I'd be able to tackle.

I can provide a wiring diagram tomorrow, I am pretty sure it is wired up correctly as I'm able to operate each axis individually until I add both codes axis and then it seems to negate the second axis listen in the code (so if axisX alone is running, it works, if axisY is running alone it works but when I add both axisX and axisY whichever is listed first in the code works and the second one listed does not)

That is good but if it does not work properly???

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.