Advertisement
KRITSADA

ATX2 PS2X simple Joy Analog show at GLCD

Oct 2nd, 2016
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <ATX2.h>  
  2. int LX,LY,RX,RY;
  3. #include <PS2X_lib.h>  
  4. #define PS2_DAT 30  
  5. #define PS2_CMD 29  
  6. #define PS2_SEL 28  
  7. #define PS2_CLK 27  
  8. PS2X ps2x ;
  9. void setup(){
  10.   delay(1000);
  11.   setTextSize(2); glcd(0,0,"Connecting");
  12.   while(true){
  13.     int error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT,0,0);
  14.     if(error==0){
  15.       glcd(0, 0, "OK ");
  16.       delay(1000);  glcdClear();  break;
  17.     }
  18.     delay(500);
  19.   }
  20. }
  21. void loop(){
  22.   ps2x.read_gamepad(0,0);
  23.   LX=ps2x.Analog(PSS_LX);   glcd(0,0,"LX=%d  ",LX);
  24.   RX=ps2x.Analog(PSS_RX);   glcd(1,0,"RX=%d  ",RX);
  25.   LY=ps2x.Analog(PSS_LY);   glcd(2,0,"LY=%d  ",LY);
  26.   RY=ps2x.Analog(PSS_RY);   glcd(3,0,"RY=%d  ",RY);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement