Author Topic: analog sticks with ps2x.h and ps2 controller  (Read 1760 times)

0 Members and 1 Guest are viewing this topic.

Offline RhysHornerTopic starter

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
analog sticks with ps2x.h and ps2 controller
« on: September 14, 2012, 06:52:09 PM »
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)
        Serial.println("Triangle pressed");
        if (digitalRead(ps2x.Button(PSB_GREEN)) == false){                                                   
        digitalWrite(greenled, HIGH);   }                                               
        else {                                                 
        digitalWrite(greenled, LOW); } 
        Serial.println("Triangle Released");

anyone advise?

Thanks in advance,
Rhys Horner
email: [email protected]


Get Your Ad Here