Hi, me and my team are new to the arduino programming language. We are tying to run the test the connection between the robotshop.com/en/lynxmotion-ps2-controller-v4.html
and the arduino Mega 2560 by using the [font=Verdana][highlight=#ffffff]Bill Porter’s PS2 library. [/highlight][/font]
[font=Verdana][highlight=#ffffff]When ever we try it we keep getting the errors:[/highlight][/font]
[font=Verdana][highlight=#ffffff]
[font=Verdana, Arial, sans-serif, Tahoma]In member function ‘void PS2X::read_gamepad(boolean, byte)’:[/font][font=Verdana, Arial, sans-serif, Tahoma][/font][font=Verdana, Arial, sans-serif, Tahoma]and[/font][font=Verdana, Arial, sans-serif, Tahoma][/font][font=Verdana, Arial, sans-serif, Tahoma]warning: narrowing conversion of ‘motor2’ from ‘byte {aka unsigned char}’ to ‘char’ inside { } -Wnarrowing][/font][font=Verdana, Arial, sans-serif, Tahoma][/font][font=Verdana, Arial, sans-serif, Tahoma]char dword[9] = {0x01,0x42,0,motor1,motor2,0,0,0,0};[/font]
[/highlight][/font]
So any arduino veterans out there can you help explain what are problem is.
Sample program:
[code]#include <PS2X_lib.h>
PS2X PS2X;
int error = 0;
byte type = 0;
byte vibrate = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(57600);
error = PS2X.config_gamepad(29,25,27,23, true, true); //(clock, command, attention, data, Pressures?, Rumble?)
if(error == 0){
Serial.println(“Found Controller, configured successful”);
Serial.println(“Try out all the buttons, X will vibrate the controller, faster as you press harder;”);
Serial.println(“holding L1 or R1 will print out the analog stick values.”);
Serial.println(“Go to http://www.billporter.info for updates and to report bugs.”);
}
else if(error == 1)
Serial.println(“No controller found, check wiring”);
else if(error == 2)
Serial.println(“Controller found but not accepting commands.”);
else if(error == 3)
Serial.println("Controller refusing to enter Pressures mode, may not support it. ");
type = PS2X.readType();
switch(type) {
case 0:
Serial.println(“Unknown Controller type”);
break;
case 1:
Serial.println(“DualShock Controller Found”);
break;
}
}
void loop(){
if(error == 1)
return;
else if(type==2){
PS2X.read_gamepad(false, vibrate);
if(PS2X.Button(PSB_START))
Serial.println(“Start is being held”);
if(PS2X.Button(PSB_SELECT))
Serial.println(“Select is being held”);
if(PS2X.Button(PSB_PAD_UP)) {
Serial.print("Up held this hard: ");
Serial.println(PS2X.Analog(PSAB_PAD_UP), DEC);
}
if(PS2X.Button(PSB_PAD_RIGHT)){
Serial.print(“Right held this hard: “);
Serial.println(PS2X.Analog(PSAB_PAD_RIGHT), DEC);
}
if(PS2X.Button(PSB_PAD_LEFT)){
Serial.print(“LEFT held this hard: “);
Serial.println(PS2X.Analog(PSAB_PAD_LEFT), DEC);
}
if(PS2X.Button(PSB_PAD_DOWN)){
Serial.print(“DOWN held this hard: “);
Serial.println(PS2X.Analog(PSAB_PAD_DOWN), DEC);
}
else{
Serial.print(“ERROR, no Dualshock controoler found”);
Serial.end();
}
vibrate = PS2X.Analog(PSAB_BLUE);
if (PS2X.NewButtonState()) {
if(PS2X.Button(PSB_L3))
Serial.println(“L3 pressed”);
if(PS2X.Button(PSB_R3))
Serial.println(“R3 pressed”);
if(PS2X.Button(PSB_L2))
Serial.println(“L2 pressed”);
if(PS2X.Button(PSB_R2))
Serial.println(“R2 pressed”);
if(PS2X.Button(PSB_GREEN))
Serial.println(“Triangle pressed”);
}
if(PS2X.ButtonPressed(PSB_RED))
Serial.println(“Circle just pressed”);
if(PS2X.ButtonReleased(PSB_PINK))
Serial.println(“Square just released”);
if(PS2X.NewButtonState(PSB_BLUE))
Serial.println(“X just changed”);
if(PS2X.Button(PSB_L1) || PS2X.Button(PSB_R1))
{
Serial.print(“Stick Values:”);
Serial.print(PS2X.Analog(PSS_LY), DEC);
Serial.print(”,”);
Serial.print(PS2X.Analog(PSS_LX), DEC);
Serial.print(”,”);
Serial.print(PS2X.Analog(PSS_RY), DEC);
Serial.print(”,”);
Serial.println(PS2X.Analog(PSS_RX), DEC);
}
}
delay(50);
}[/code]
^