Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
boolean calibrate(uint8_t deadzone) const{ sonyPS2_calibrate(m_cstr,deadzone);}
boolean calibrate(uint8_t deadzone) const{ return sonyPS2_calibrate(m_cstr,deadzone);}
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){ marquee.print_P(PSTR("Fergybot4000 by Tony Tzankoff\n")); controller.calibrate(20); return 0;
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){ if (!controller.isAnalogMode()) // added this because sometimes the connection would break { controller.setAnalogMode(); } // code will be inserted here to drive a pair of wheelchair motors hooked up to a Sabertooth 2x25 // moves servos stickVal=controller.joystick(PS2_STICK_LEFT_Y); servoVal[2]=servoMoveServo(2,stickVal,1); stickVal=controller.joystick(PS2_STICK_RIGHT_X); servoVal[1]=servoMoveServo(1,stickVal,1); // code for buttons if (controller.buttonsChanged()) { stickVal=controller.buttonsRaw(); switch(stickVal) { case 1024: // L1 functionSomething(); break; // additional cases follow } }
Like before, the wired controller works just fine whereas the wireless controller does not (both before and after the resistor was added).
// Define constants for buttons. These can be ORed together#define PS2_BTN_SELECT 0x0001u#define PS2_BTN_L3 0x0002u#define PS2_BTN_R3 0x0004u#define PS2_BTN_START 0x0008u#define PS2_DPAD_UP 0x0010u#define PS2_DPAD_RIGHT 0x0020u#define PS2_DPAD_DOWN 0x0040u#define PS2_DPAD_LEFT 0x0080u#define PS2_BTN_L2 0x0100u#define PS2_BTN_R2 0x0200u#define PS2_BTN_L1 0x0400u#define PS2_BTN_R1 0x0800u#define PS2_BTN_TRIANGLE 0x1000u#define PS2_BTN_CIRCLE 0x2000u#define PS2_BTN_X 0x4000u#define PS2_BTN_SQUARE 0x8000u
Just to clarify the above: the PS2 code works - but not for a wireless (LynxMotion) controller?
@tzankoff Looking at your code you are testing for fixed values. ie your 'case 1024' could be replaced by a more meaningful 'case PS2_BTN_L1' as all the button values are defined for you in ps2.h
Everything kept returning 0, which said to me I was doing something wrong.
Note some controllers work better with 3.3v, so you might try that.
Also to get a receiver to connect to a transmitter, you might try only applying power and ground to it, turn on power, then turn on power to remote and see if the two lights on receiver comes on solid. Pressing analog button, should force analog light to come on for awhile.
#define MAKE_SONY_PS2(select) { \ MAKE_SPI_DEVICE(SPI_MODE_2,SPI_DATA_ORDER_LSB,select,0xff), \ 255,255, \ {255,255,128,128,128,128}, \ {128,128,128,128}, \ 27, \ FALSE, 0, FALSE,\ 0}