Arduino & PS2 controller help

Anything to do with programing the Arduino Platform.
Post Reply
User avatar
PhilA
Posts: 42
Joined: Oct 1st, 2017, 12:53 am
Location: Australia

Arduino & PS2 controller help

Post by PhilA »

Hi there,

I am fairly new to Arduino and need some help tweaking a program. I have been looking at the Arduino program V1 for an ROV by Hamish Trove on the below webpage which is 2 x Nano communicating over serial, using a PS2 controller.

http://www.techmonkeybusiness.com/rov-c ... ition.html

I am trying to change the Headlights function from an on/off toggle function to a momentary switch function where you hold the PS2 button and the lights go on and then when released lights go off. I am using 2 LED's (1 on Master and 1 on Slave) to show if the switch function is working properly.

I've had a few goes amending the code but get a lot of flickering and inconsistency?

Any ideas greatly appreciated.

Many thanks
User avatar
PhilA
Posts: 42
Joined: Oct 1st, 2017, 12:53 am
Location: Australia

Re: Arduino & PS2 controller help

Post by PhilA »

Well I managed to get some advice and this was the solution from a different forum which worked. :)


Replace this:


Code:
---------
if(ps2x.ButtonPressed(PSB_PAD_LEFT)) //Pressed
{
txdata.LEDHdlts = !txdata.LEDHdlts; //Toggle the LED light flag
}
---------
With this...

Code:
---------
txdata.LEDHdlts = ps2x.Button(PSB_PAD_LEFT);
---------
Post Reply