Issues communicating Lynxmotion PS2 v4 with Arduino Mega

Hello,

I recently purchased a Lynxmotion PS2 v4 controller (http://www.lynxmotion.com/p-1096-ps2-robot-controller-v4.aspx). I’m using an Arduino Mega 2560, and have done research using the RobotShop forums about how to wire it properly. I am attempting to run the example code for Arduino Mega from the Lynxmotion version of the PS2X library (https://github.com/Lynxmotion/Arduino-PS2X) but I receive the following error:

No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips
Unknown Controller type

I uncommented the debug lines from the .h file and received (excluding all of the OUT:IN Configure lines):

Controller mode not matched or no controller found
Expected 0x41 or 0x73, got FF
No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips
Unknown Controller type

I have pictures of my most current set-up attached.

My pin out is as follows:
DAT to digital pin 12
CMD to digital pin 11
ATT to digital pin 10
CLK to digital pin 13
GND to GND and 5V to 5V

I’ve tried using both 3.3V power and 5V power with no change. When the receiver and the controller both have power, the LED on the receiver and the controller light up solid green. Based on this forum - Is my lynxmotion PS2 wireless controller defective? - that means the receiver and controller are connected to each other. The two AAA batteries in the controller are fresh out of the packaging.

Originally I was using this set up with a Mega that had a LSS adapter board connected to it. To try to eliminate possible variables I tried using a second Mega without the adapter board attached (the adapter boards are extremely hard to remove so it was easier for me to simply use a second one). Both Megas have been used successfully in the past to run other scripts so I don’t believe it’s an issue with the Mega.

I’ve read through forum posts with similar topics, but have not been able to figure out the issue. Any help would be greatly appreciated!

Receiving 0xFF would normally indicate that the data line always stays high (instead of varying).

I assume you’ve changed the initialization of the PS2 object to match your pinout?

The receiver is a 5 V DC device. I recommend sticking to that voltage.

That is good news. It at least confirms the wireless part is working. Unfortunately, it does not tell us much concerning the state of the serial communication between the PS2 receiver and the BotBoarduino.

Good idea. The first step to fixing most problem is identifying the base/minimal case.

The easiest in such a case would be to use a logic analyzer on all 4 digital pins to monitor communication between the PS2 receiver and the BotBoarduino.

Overall, the issue is either: the physical connections & init of the PS2 pinout don’t match, the PS2 receiver does not work properly (on that point, has it worked previously?) or one or more of the pins (10/11/12/13) on your Arduino Mega 2560 do not work.

The first point (pinout matching) is pretty straightforward to check. According to what you posted above and your pictures those seem to match. Just make sure it matches in the code too (using the right order). The order according to the library itself is:

[code]
byte PS2X::config_gamepad(uint8_t clk, uint8_t cmd, uint8_t att, uint8_t dat, bool pressures, bool rumble) {
[/quote]
According to this, your code should have:`

error = ps2x.config_gamepad(13, 11, 10, 12, ???, ???);

For the last point, you should be able to easily test pins 10/11/12/13 using an LED + resistor (for digital output) and with a resistor and button or simply a wire (for digital input) to confirm they each are functioning properly.

If you can cover both of these we’ll most likely be left with the conclusion that your PS2 receiver is damaged or defective.

Let me know how the testing goes!

Sincerely,

It looks like the default pin numbers in the example were different from the ones I was using. I changed the pin numbers in ps2x.config_gamepad and it works beautifully. Thank you!

1 Like

Ah ha! :smiley: With embedded systems, the simplest answer is usually the correct one… :smiley:

Good! Enjoy the parts and good luck with your project!

Sincerely,