Playstation 2 controler and bot boarduino

Remember that there are no spaces in methods or functions. You wrote digital write(led,high); it should look like this: digitalWrite(led,HIGH); in programming the way you format the text is very important; however, you seem to have a correct understanding.

This is my frist baby step and i hit the wall. It tells me that pinmode was not decleard in this scope whats did i miss? This is what i changed in the code. :blush:

[code]#include <PS2X_lib.h>

PS2X ps2x; // create PS2 Controller Class

//right now, the library does NOT support hot pluggable controllers, meaning
//you must always either restart your Arduino after you conect the controller,
//or call config_gamepad(pins) again after connecting the controller.

byte vibrate = 0;

void setup(){
ps2x.config_gamepad(9,7,8,6); //setup GamePad(clock, command, attention, data) pins
ps2x.enableRumble(); //enable rumble vibration motors
ps2x.enablePressures(); //enable reading the pressure values from the buttons.

Serial.begin(57600);
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 www.billporter.info for updates and to report bugs.”);
}

void loop(){
/* You must Read Gamepad to get new values
Read GamePad and set vibration values
ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255)
if you don’t enable the rumble, use ps2x.read_gamepad(); with no values

you should call this at least once a second
*/
ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at ‘vibrate’ speed
PINMode led,13
if(ps2x.Button(PSB_START)) //will be TRUE as long as button is pressed
digitalwrite(led,HIGH);
if(ps2x.Button(PSB_SELECT))
Serial.println(“Select is being held”);

if(ps2x.Button(PSB_PAD_UP)) { //will be TRUE as long as button is pressed
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);
}

vibrate = ps2x.Analog(PSAB_BLUE);        //this will set the large motor vibrate speed based on 
                                        //how hard you press the blue (X) button    

if (ps2x.NewButtonState()) //will be TRUE if any button changes state (on to off, or off to on)
{

  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)) //will be TRUE if button was JUST pressed
Serial.println(“Circle just pressed”);

if(ps2x.ButtonReleased(PSB_PINK)) //will be TRUE if button was JUST released
Serial.println(“Square just released”);

if(ps2x.NewButtonState(PSB_BLUE)) //will be TRUE if button was JUST pressed OR released
Serial.println(“X just changed”);

if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) // print stick values if either is TRUE
{
Serial.print(“Stick Values:”);
Serial.print(ps2x.Analog(PSS_LY), DEC); //Left stick, Y axis. Other options: LX, RY, RX
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]

In c/c++ things are case sensitive, so it is pinMode. Look at arduino help for more details.
arduino.cc/en/Reference/PinMode

pinMode(13,OUTPUT);

I changed the pin mode and fallowed the example and when i try to upload it highlights

if(ps2x.Button(PSB_SELECT)) is there a website that has a blink code or a outline that i can use to fell in with a code? :bulb: I think I’m close but i feel like the example code is not a good place to start ? any pointers is welcomed

The compiler prints errors at the bottom of the IDE…

It said that it cant define type. When i jest tryed it

I just had to define led
int led = 13;
changed
PINMode led,13
to
pinMode(led, OUTPUT);
and
digitalwrite(led,HIGH);
to
digitalWrite(led,HIGH);

and it compiled for me. Like Kurte mentioned check the reference section for case sensitive items
arduino.cc/en/Reference/DigitalWrite

Hello friend sorry for old thread reply but were you able to find the right way of using L1 and L2… I am working on it so please help if you can…

Not sure what you are asking here? Old thread with lots of stuff…

Assuming you have a valid version of Bill Porters PS2 library (Probably download version off of github/lynxmotion), you can load the example program that Bill Porter did. With Arduino IDE up, go to file menu select examples menu item, under that select PS2X and follow the menu items down until you get to the PS2 examples sketch… Exact menu items are shown in other parts of this thread. This example shows using L1 and L2…

But assuming you have any of the PS2 stuff working. Your code should do something like:

// Start of PS2 processing... Note I usually put this somewhere in a subroutine.   Could be part of main Loop functrion.
ps2x.read_gamepad(); 
.... Some other processing.
if (ps2x.ButtonPressed(PSB_L1)) {// L1 Button Test
    ; do whatever you want to do when L1 is pressed.
}
if (ps2x.ButtonPressed(PSB_L2)) {// L2 Button Test
    ; do whatever you want when L2 is pressed.
}
...

Is these code for Phoenix hexapod witz ssc-32 /botboarduino and ps2 ?
On forum i founded only code for h3 model
Thanks you
Xavier