Hello all,
The story... I am using my arduino to control some LED's using a ps2 controller and the ps2x.h library (found on mind of bill porter).
I got the controller talking to the arduino and pc, showing serial.print commands on the serial monitor.
I managed to get the buttons to output digital signals to turn the LED's on and off (on while button is pressed and off when button is released).
The issue I need help with is utilizing the analog signals given by the analog sticks and/or the analog signals given by the directional buttons.
the code I used for the digital signals i will copy/paste in.
the LED variable is "greenled" which is an "int" and the pinmode is set to "OUTPUT"
if (ps2x.NewButtonState()) //will be TRUE if any button changes state (on to off, or off to on)
{
if(ps2x.Button(PSB_GREEN))
Serial.println("Triangle pressed");
if (digitalRead(ps2x.Button(PSB_GREEN)) == false){
digitalWrite(greenled, HIGH); }
else {
digitalWrite(greenled, LOW); }
if(ps2x.ButtonReleased(PSB_GREEN))
Serial.println("Triangle Released");
anyone advise?
Thanks in advance,
Rhys Horner
email:
[email protected]