xbox or ps3/4 controller, to usb shield

The short question is which controller is the easiest to use? Have Mega 2560 and USB host shield, bought a wired ProjectA xbox one controller off amazon (has good reviews and extra buttons), but I can't get it to connect or power on from arduino, now I'm wondering if this controller is too fancy? Ran qc on shield, appears fine, keyboard works and usb shield provides 5V Vbus. Controller appears fine when plug into computer. I need 6 joystick axis (so the two main joysticks, and the 2 triggers need to be potentiometers...not sure which controllers have this, I have no experience with game consoles).

So longer story, I'm looking to wireless control a hydraulic crane. Need 6 potentiometer/PWM type controls and 10~20 buttons/switches (or something similar/equivalent). I built a switch and potentiometer box to work everything, the 6 hydraulic valves need a variable voltage 3~9V (relative to nominal 12V) to control, everything else is 12VDC switched on/off. I have an optocoupled relay board (for the PWM hydraulic valves) and relay board both rated for 12V, both controllable by 5v from an Arduino (don't have any code yet).

I need to control these functions wireless, preferably up to 100 ft away, might have obstructions, so I like the NRF24l01. I also really like the idea of a standard controller like the xbox or playstation since they're cheap, easily replaceable, and some wireless. I'd love to get a wireless controller and go directly to the main arduino (currently have Mega 2560), but the ~30 ft range may not be enough so I may need something else, not sure yet.

I don't mind baby steps, so I expect to work on a wired/easier option first with one arduino before trying a second wireless control, and extended range may be another stage. Two options I'm thinking of for the extended range, one would be get a wired controller and plug into a 2nd arduino/usb shield, read the controller signal, then send wireless thru nrf24l01 to main arduino on the crane. 2nd thought is to get a wireless controller, and somehow scab inside a nrf24l01 or similar to force the signal thataway and catch it with the one arduino on the crane...not sure if that's possible though, I just like the idea of only one microcontroller. Easy/reliable is more important than slick.

I assume You're building a little modell crane. Correct?

lol...no, full size. Its an old power company derrick digger crane that I got to (eventually) build our house with. It used to have a wireless controller, removed before I purchased, but hydraulic valves are already setup to accept PWM/12V inputs. Terex ballparked me ~$10k for one...China even quoted me ~$3k. Used units are on Ebay for like $1k, but I've never seen a matched transmitter/reciever, for whatever reason, and OEM won't provide any help plus they're all listed as used/unknown condition, so feels like it'd be tossing money down the drain.

I understand Your interrest in Your project. I could have taken it on for my private use.
However, Arduinos are not certified, approved, for such tasks. There's a lot of safety concerns, regulations... to pay attention to.

For many years I was the designer of the logics for multi ton forklift trucks and that has given me respect for machines like that.

Bring up a table hobby project and I'll support You.

Hobbyist answers (some, many..) from here are not recommended.

As far as I know, the controller probably has only 5 axes, left stick with 2 axes, right stick with 2 axes, and left trigger + right trigger is one axis. I don't have an xbox controller but Logitech controllers. I did some tests. Under XInput mode, that was what I got. Under directInput, the triggers are buttons so only 4 axes.

I agree with Railroader. Hobby projects are welcome here but serious projects with heavy machines are not recommended on the forum.

OK, I've read through the TOS and forum rules and didn't see anything limiting the scope, nor am I aware of any laws or regulations I'd be approaching, but I'm not gonna complain if I don't get free help. I was just doing what the rules requested, which was to provide detail and the end goal. I thought a real world project would be something cool to talk about, but I guess not, and I probably have a lot of toys to build first anyway.

I'd still like to figure out this controller thing, I'm just trying to figure out if I'm doing something wrong or if I should get another controller. I've researched and bought enough of this arduino stuff by now, that crane or no crane I'd still like to get something choochin.

There may not be any forum rules against discussing potentially dangerous but totally ligitimate projects. We just don't want you to get hurt or get others hurt because the quality of arduino software and hardware is not intended for such applications.

Regarding game controller recommendations, I have Logitech so it may not work because the triggers are one axis. Since you already have an xbox one controller, can you post the VID and PID of your controller? Go to device manager and find them, under the device, properties, details, hardware IDs.

I have a versoin of UHS V2.0 that specifies these ids (wired controller?)

// PID and VID of the different versions of the controller - see: https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c

// Official controllers
#define XBOX_VID1                               0x045E // Microsoft Corporation
#define XBOX_ONE_PID1                           0x02D1 // Microsoft X-Box One pad
#define XBOX_ONE_PID2                           0x02DD // Microsoft X-Box One pad (Firmware 2015)
#define XBOX_ONE_PID3                           0x02E3 // Microsoft X-Box One Elite pad
#define XBOX_ONE_PID4                           0x02EA // Microsoft X-Box One S pad
#define XBOX_ONE_PID13                          0x0B0A // Microsoft X-Box One Adaptive Controller

// Unofficial controllers
#define XBOX_VID2                               0x0738 // Mad Catz
#define XBOX_VID3                               0x0E6F // Afterglow
#define XBOX_VID4                               0x0F0D // HORIPAD ONE
#define XBOX_VID5                               0x1532 // Razer
#define XBOX_VID6                               0x24C6 // PowerA

#define XBOX_ONE_PID5                           0x4A01 // Mad Catz FightStick TE 2 - might have different mapping for triggers?
#define XBOX_ONE_PID6                           0x0139 // Afterglow Prismatic Wired Controller
#define XBOX_ONE_PID7                           0x0146 // Rock Candy Wired Controller for Xbox One
#define XBOX_ONE_PID8                           0x0067 // HORIPAD ONE
#define XBOX_ONE_PID9                           0x0A03 // Razer Wildcat
#define XBOX_ONE_PID10                          0x541A // PowerA Xbox One Mini Wired Controller
#define XBOX_ONE_PID11                          0x542A // Xbox ONE spectra
#define XBOX_ONE_PID12                          0x543A // PowerA Xbox One wired controller

I guess if your id is not included, it won't work. If you have a wireless controller with BT,I don't have any xbox one controllers to help you, wired or not. This is as far as I know about these controllers.

Thanks for the pictures. You've got a good piece of equipment there.
What about thinking of a manual control station on the truck using manual levers operating the crane?

USB\VID_24C6&PID_592A&REV_0101
USB\VID_24C6&PID_592A

It's the PowerA Spectra Enhanced Illuminated Wired Controller for Xbox One, X and Xbox One S - Xbox One

I see the VID, but not the PID, so I guess I need another controller, or is there a way to change this or add it somehow? I picked this controller because a few reviewers said the triggers and joysticks are more accurate, but I'm not really tied to it. The controller lights do not come on when I plug into a power outlet, so seems it needs some communication before the lights turn on.

I was also scanning the code on the USB Host Shield examples, and now I'm not sure if it even recognizes a potentiometer or force signal from the controller. For LT and RT it just calls it a button

/*
 Example sketch for the Xbox ONE USB library - by guruthree, based on work by
 Kristian Lauszus.
 */

#include <XBOXONE.h>

// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>

USB Usb;
XBOXONE Xbox(&Usb);

void setup() {
  Serial.begin(115200);
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
  if (Usb.Init() == -1) {
    Serial.print(F("\r\nOSC did not start"));
    while (1); //halt
  }
  Serial.print(F("\r\nXBOX USB Library Started"));
}
void loop() {
  Usb.Task();
  if (Xbox.XboxOneConnected) {
    if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
      if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) {
        Serial.print(F("LeftHatX: "));
        Serial.print(Xbox.getAnalogHat(LeftHatX));
        Serial.print("\t");
      }
      if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) {
        Serial.print(F("LeftHatY: "));
        Serial.print(Xbox.getAnalogHat(LeftHatY));
        Serial.print("\t");
      }
      if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) {
        Serial.print(F("RightHatX: "));
        Serial.print(Xbox.getAnalogHat(RightHatX));
        Serial.print("\t");
      }
      if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
        Serial.print(F("RightHatY: "));
        Serial.print(Xbox.getAnalogHat(RightHatY));
      }
      Serial.println();
    }

    if (Xbox.getButtonPress(L2) > 0 || Xbox.getButtonPress(R2) > 0) {
      if (Xbox.getButtonPress(L2) > 0) {
        Serial.print(F("L2: "));
        Serial.print(Xbox.getButtonPress(L2));
        Serial.print("\t");
      }
      if (Xbox.getButtonPress(R2) > 0) {
        Serial.print(F("R2: "));
        Serial.print(Xbox.getButtonPress(R2));
        Serial.print("\t");
      }
      Serial.println();
    }

    // Set rumble effect
    static uint16_t oldL2Value, oldR2Value;
    if (Xbox.getButtonPress(L2) != oldL2Value || Xbox.getButtonPress(R2) != oldR2Value) {
      oldL2Value = Xbox.getButtonPress(L2);
      oldR2Value = Xbox.getButtonPress(R2);
      uint8_t leftRumble = map(oldL2Value, 0, 1023, 0, 255); // Map the trigger values into a byte
      uint8_t rightRumble = map(oldR2Value, 0, 1023, 0, 255);
      if (leftRumble > 0 || rightRumble > 0)
        Xbox.setRumbleOn(leftRumble, rightRumble, leftRumble, rightRumble);
      else
        Xbox.setRumbleOff();
    }

    if (Xbox.getButtonClick(UP))
      Serial.println(F("Up"));
    if (Xbox.getButtonClick(DOWN))
      Serial.println(F("Down"));
    if (Xbox.getButtonClick(LEFT))
      Serial.println(F("Left"));
    if (Xbox.getButtonClick(RIGHT))
      Serial.println(F("Right"));

    if (Xbox.getButtonClick(START))
      Serial.println(F("Start"));
    if (Xbox.getButtonClick(BACK))
      Serial.println(F("Back"));
    if (Xbox.getButtonClick(XBOX))
      Serial.println(F("Xbox"));
    if (Xbox.getButtonClick(SYNC))
      Serial.println(F("Sync"));

    if (Xbox.getButtonClick(L1))
      Serial.println(F("L1"));
    if (Xbox.getButtonClick(R1))
      Serial.println(F("R1"));
    if (Xbox.getButtonClick(L2))
      Serial.println(F("L2"));
    if (Xbox.getButtonClick(R2))
      Serial.println(F("R2"));
    if (Xbox.getButtonClick(L3))
      Serial.println(F("L3"));
    if (Xbox.getButtonClick(R3))
      Serial.println(F("R3"));


    if (Xbox.getButtonClick(A))
      Serial.println(F("A"));
    if (Xbox.getButtonClick(B))
      Serial.println(F("B"));
    if (Xbox.getButtonClick(X))
      Serial.println(F("X"));
    if (Xbox.getButtonClick(Y))
      Serial.println(F("Y"));
  }
  delay(1);
}

But the PS3 does state to get analog signal from L2 and R2, so maybe that's my answer

/* (truncated for forum's post length limit)

void loop() {
 Usb.Task();

 if (PS3.PS3Connected || PS3.PS3NavigationConnected) {
   if (PS3.getAnalogHat(LeftHatX) > 137 || PS3.getAnalogHat(LeftHatX) < 117 || PS3.getAnalogHat(LeftHatY) > 137 || PS3.getAnalogHat(LeftHatY) < 117 || PS3.getAnalogHat(RightHatX) > 137 || PS3.getAnalogHat(RightHatX) < 117 || PS3.getAnalogHat(RightHatY) > 137 || PS3.getAnalogHat(RightHatY) < 117) {
     Serial.print(F("\r\nLeftHatX: "));
     Serial.print(PS3.getAnalogHat(LeftHatX));
     Serial.print(F("\tLeftHatY: "));
     Serial.print(PS3.getAnalogHat(LeftHatY));
     if (PS3.PS3Connected) { // The Navigation controller only have one joystick
       Serial.print(F("\tRightHatX: "));
       Serial.print(PS3.getAnalogHat(RightHatX));
       Serial.print(F("\tRightHatY: "));
       Serial.print(PS3.getAnalogHat(RightHatY));
     }
   }
   // Analog button values can be read from almost all buttons
   if (PS3.getAnalogButton(L2) || PS3.getAnalogButton(R2)) {
     Serial.print(F("\r\nL2: "));
     Serial.print(PS3.getAnalogButton(L2));
     if (!PS3.PS3NavigationConnected) {
       Serial.print(F("\tR2: "));
       Serial.print(PS3.getAnalogButton(R2));
     }
   }

And Railroader, I did build a control box, seems to work good although it's just clunky and is not easy to hold/operate...hence the rabbit hole leading me to ps/xbox controller. The crane has manual hydraulic levers, but don't work well (some functions are only servo actuated), and my little joystick box has way way more precision, the levers are just intended as a backup.

I supposed I could do a "control station", but the problem with that, for me at least, is I need to have easy control as close to the work as possible, since I'll either be working alone or at best one other person (and you can bet that if I have one other person, they're not likely to be reliable enough to be on either end of the operation).

As for a little background, I was a mechanical, then welding engineer...quit to move to the mountains, started a contracting/renovation business (have renovated 4 of my own houses prior). Have built large 2-story decks and several additions by myself, so I'm no stranger to this stuff. semi-skilled labor is almost non-existent around here, so the crane will be my crew. Pandemic hit, stopped contracting, wife started a new business, I'm at home with the kids staring at a crane trying to thick up ways to make my life easier once I can actually start building our house.

Just hijack one of the PID's under your VID.

I suspect that the driver is a direct Input type that turns the triggers into buttons. I recommend you to test with the Xbox one controller before getting another one.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.