/********************************************** * e-Gizmo PS2Controller - PS2Controlled.ino * * This is an example codes for using the * Universal Ps2 Controller with UHF Receiver Only. * * PBOT.COL1_RIGHT(); * PBOT.COL2_CENTER(); * PBOT.COL3_LEFT(); * * * * Codes by * e-Gizmo Mechatronix Central * http://www.e-gizmo.net * October 18,2019 ************************************************/ #include eGizmo_PS2Controller ps2Data(&Serial); void setup(){ //Initialize PS2 & PBOT ps2Data.begin(9600); while(!ps2Data.update()); } void loop(){ //Query PS2 cotroller data, wait for valid inputs if(ps2Data.update()){ //Left and Right Josyticks Serial.print("Left JS : "); Serial.print(ps2Data.leftx); Serial.print(","); Serial.println(ps2Data.lefty); Serial.print("Right JS : "); Serial.print(ps2Data.rightx); Serial.print(","); Serial.println(ps2Data.righty); //Up,Down,Left, and Right Buttons if(ps2Data.up){ Serial.println("UP"); } if(ps2Data.down){ Serial.println("DOWN"); } if(ps2Data.left){ Serial.println("LEFT"); } if(ps2Data.right){ Serial.println("RIGHT"); } //Triangle,Cross,Square, and Circle Buttons if(ps2Data.triangle){ Serial.println("TRIANGLE"); } if(ps2Data.cross){ Serial.println("CROSS"); } if(ps2Data.square){ Serial.println("SQUARE"); } if(ps2Data.circle){ Serial.println("CIRCLE"); } //Left 1 & 2 and Right 1 & 2 buttons if(ps2Data.left1){ Serial.println("LEFT 1"); } if(ps2Data.left2){ Serial.println("LEFT 2"); } if(ps2Data.right1){ Serial.println("RIGHT 1"); } if(ps2Data.right2){ Serial.println("RIGHT 2"); } //Start Button if(ps2Data.start){ Serial.println("START"); } } }