# Xbox Controller + Stepper motors

**URL:** <https://discourse.processing.org/t/xbox-controller-stepper-motors/20818>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [May 13, 2020, 9:40am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818 "2020-05-13T09:40:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 13, 2020, 9:40am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/1 "2020-05-13T09:40:45Z")

</div>

Hello everyone,  
my name is Taniq, I am from Slovakia, Bratislava.I would like to ask for help. Recently I found a video on youtube, demonstration how to control with Xbox360 servo motors.I was very impressed from the interface of Processing and how easy actually works to control a servo motor.  
Here is the link of the video:

[![](https://img.youtube.com/vi/6CmIidOxc2g/maxresdefault.jpg "Controlling Arduino with Javascript Using the Johnny Five Library") ](https://www.youtube.com/watch?v=6CmIidOxc2g&t=25s)

My question is:  
Is there a library that I can use for a Stepper motors? Example code will be helpful.  
Thanks in advance.

ps.  
I’ve build a robot arm that is using 6 stepper motors and since i don’t have a pedant I do believe with a controller like Xbox will work out 🙂

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 13, 2020, 10:03am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/2 "2020-05-13T10:03:37Z")

</div>

Hello!

And welcome to the forum!

Great to have you here!

Actually the recommended hardware is Arduino (not Xbox), processing related.

As the title says it:

- Controlling Arduino with Javascript Using the Johnny Five Library

Also, please read the description on YouTube:

- Build guide, diagrams, code etc over on the written article…

**See also:**

[https://www.processing.org/tutorials/electronics/](https://www.processing.org/tutorials/electronics/)

[https://www.arduino.cc/](https://www.arduino.cc/)

> **[Arduino](https://en.wikipedia.org/wiki/Arduino)**
>
> Arduino is an open-source hardware and software company, project and user community that designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices. Its products are licensed under the GNU Lesser General Public License (LGPL) or the GNU General Public License (GPL), permitting the manufacture of Arduino boards and software distribution by anyone. Arduino boards are available commercially in preassembled form or as do-it-yourself (DIY) kits.
> Ardui...

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 13, 2020, 10:11am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/3 "2020-05-13T10:11:55Z")

</div>

Hello Chrisir,  
maybe my question wasn’t so clear. I know arduino and i can work with it. But I am not sure that using the Gamecontrol from Processing for the controller will work out same way with stepper motors, as for the servo motor in the article? In the video the man explains brefly how many libraries are included in order to use arduino and communication with it, but it seems to me that all of them are for the servo motors…  
Commands in the his program like digitalWrite(10, High) and etc…are related to a servo motor. Calling line arduino.Servo and etc…as well…  
So this is what made me to aks for a help. Can I use the same method with xbox controller processing and arduino to control stepper motor? 🙂  
thanks for the links…  
I am about 2 days already searching for information … but since everyone has different ideas(world is big and creative) i still cannot find helfpul artcile.  
Smile,  
Taniq

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 13, 2020, 10:19am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/4 "2020-05-13T10:19:27Z")

</div>

> **[JavaScript Robotics Examples (Johnny-Five)](http://johnny-five.io/examples/)**
>
> Johnny-Five is the original JavaScript Robotics & IoT Platform. Released by Bocoup in 2012, Johnny-Five is maintained by a community of passionate software developers and hardware engineers. Over 75 developers have made contributions towards...

Oh maybe you mean this one. I will have a look more detials now. Thank you

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 13, 2020, 10:52am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/5 "2020-05-13T10:52:45Z")

</div>

Did you read the description on YouTube?

So you want to run the Arduino code on a Xbox? Why. Arduino is cheap.

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 13, 2020, 2:50pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/6 "2020-05-13T14:50:20Z")

</div>

Yes I read it.  
No I want to use my xbox controller to operate an robot arm with stepper motors.  
In his examples and in mostly every robotic projects he works with a servo motor. The difference between servo and stepper motors is quite big.  
I want to use the gamecontrol option from processing(as shown on that video) but for stepper motors.  
And yes Arduino is cheap and really powerful! It’ is not necesarely every home project to be part of rocket science :))  
Cheers  
Taniq

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 16, 2020, 4:42am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/7 "2020-05-16T04:42:16Z")

</div>

Hi @Name_itT – to confirm:

xbox controller --\> arduino --\> stepper motors --\> robot arm

This is what you want to do, right?

Which links in that chain are you asking for help with first? Which ones are you pretty confident about? I would suggest breaking this down into smaller sub-projects and stages.

It sounds like you have an xbox controller and an arduino – do you already have the robot arm with steppers? Have you been controlling it in some other way?

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 16, 2020, 12:15pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/8 "2020-05-16T12:15:38Z")

</div>

Hello Sir.  
Yes I do. You understood me well. I was just very confused from all information and insane amount of programs that everyone were posting as “the best” solution, but at the end not really the case. Yes I am new in programing but I just dont like to copy paste something which I dont understand from where it comes, why it is setup this way and etc.  
So before jump into something big I started with a small steps, related to my knowledge.

[![]( " - YouTube") ](https://www.youtube.com/watch?v=dIJxgbICcFI)

Here is a short video. My first try.  
If you would like to see the program, please do let me know. I will post it. I tried to keep it simple.  
My background is fanuc CNC programing.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 16, 2020, 4:52pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/9 "2020-05-16T16:52:48Z")

</div>

Great!!

Does the video mean that you have solved your problem, or do you still have a question?

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 16, 2020, 11:50pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/10 "2020-05-16T23:50:52Z")

</div>

Thank you.  
Well I do believe I am on the right way. However I am not sure that topic should stay open. I hope of it’s a conitnue discussion maybe would be helpful for other people. However is this require something more from me. To provide for example the final solution or ?  
Thank u …  
Have a nice evening and smile.  
Taniq

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 17, 2020, 2:01am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/11 "2020-05-17T02:01:06Z")

</div>

Yes, you may ask follow-up questions about the project here on this thread. Or you may share your solution here if you wish.

You can also post the project to the Gallery if you want to share it whenever it is finished.

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 22, 2020, 4:26am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/12 "2020-05-22T04:26:48Z")

</div>

```auto
/// Beginner program for controlling stepper motors with a joystick.

int driverPUL1 = 22; // driver slot for Pulses
int driverDIR1 = 24; // driver slot for Directon
int driverPUL2 = 26;
int driverDIR2 = 28;
int driverPUL3 = 30;
int driverDIR3 = 32;
int driverPUL4 = 34;
int driverDIR4 = 36;
int driverPUL5 = 38;
int driverDIR5 = 40;
int button = A11;
int buttonPos = 0;
int pd = 100; //pulse delay

// Anlog Pins: A8=button, A9=Y, A10=X, A11=button, A12=Y, A13=X

void setup() {
  Serial.begin(9600);
  pinMode(driverPUL1, OUTPUT); // Driver PUL1 ON
  pinMode(driverDIR1, OUTPUT); // Driver DIR1 ON

  pinMode(driverPUL2, OUTPUT); // Driver PUL2 ON
  pinMode(driverDIR2, OUTPUT); // Driver DIR2 ON

  pinMode(driverPUL3, OUTPUT); // Driver PUL3 ON
  pinMode(driverDIR3, OUTPUT); // Driver DIR3 ON

  pinMode(driverPUL4, OUTPUT); // Driver PUL4 ON
  pinMode(driverDIR4, OUTPUT); // Driver DIR4 ON

  pinMode(A11, INPUT);
  pinMode(driverPUL5, OUTPUT); // Driver PUL5 ON
  pinMode(driverDIR5, OUTPUT); // Driver DIR5 ON

}

void moveJ1() {
  int stickPos; // stick postion
  int steps = 0; // steps
  int dir; // direction

  stickPos = analogRead(A10); // reading stick position 0 to 1023

  if (stickPos > 520 || stickPos < 480) steps = (stickPos - 500) / 50; // lower divider will make high speed higher
  //Serial.println(steps);
  delay(4); // larger number of delay will make low speed lower

  if (steps > 0) dir = 1; else {
    steps = -steps;
    dir = 0;
  }

  digitalWrite(driverDIR1, dir);

  for (; steps > 0; steps--) {

    digitalWrite(driverPUL1, HIGH);
    delayMicroseconds(pd);
    digitalWrite(driverPUL1, LOW);
    delayMicroseconds(pd);
  }
}

void moveJ2() {
  int stickPos; // stick postion
  int steps = 0; // steps
  int dir; // direction

  stickPos = analogRead(A9); // reading stick position 0 to 1023

  if (stickPos > 520 || stickPos < 480) steps = (stickPos - 500) / 50; // lower divider will make high speed higher
  //Serial.println(steps);
  delay(4); // larger number of delay will make low speed lower

  if (steps > 0) dir = 1; else {
    steps = -steps;
    dir = 0;
  }

  digitalWrite(driverDIR2, dir);

  for (; steps > 0; steps--) {

    digitalWrite(driverPUL2, HIGH);
    delayMicroseconds(pd);
    digitalWrite(driverPUL2, LOW);
    delayMicroseconds(pd);
  }
}

void moveJ3() {
  int stickPos; // stick postion
  int steps = 0; // steps
  int dir; // direction

  stickPos = analogRead(A12); // reading stick position 0 to 1023

  if (stickPos > 520 || stickPos < 480) steps = (stickPos - 500) / 50; // lower divider will make high speed higher

  //Serial.println(steps);
  delay(4); // larger number of delay will make low speed lower

  if (steps > 0) dir = 1; else {
    steps = -steps;
    dir = 0;
  }

  digitalWrite(driverDIR3, dir);

  for (; steps > 0; steps--) {

    digitalWrite(driverPUL3, HIGH);
    delayMicroseconds(pd);
    digitalWrite(driverPUL3, LOW);
    delayMicroseconds(pd);
  }
}

void moveJ4() {
  int stickPos; // stick postion
  int steps = 0; // steps
  int dir; // direction

  stickPos = analogRead(A13); // reading stick position from 0 to 1023

  if (stickPos > 520 || stickPos < 480) steps = (stickPos - 500) / 50; // lower divider will make high speed higher

  //Serial.println(steps);
  delay(4); // larger number of delay will make low speed lower

  if (steps > 0) dir = 1; else {  
    steps = -steps;
    dir = 0;
  }

  digitalWrite(driverDIR4, dir);

  for (; steps > 0; steps--) {

    digitalWrite(driverPUL4, HIGH);
    delayMicroseconds(pd);
    digitalWrite(driverPUL4, LOW);
    delayMicroseconds(pd);
  }
}

void moveJ5() {
  int stickPos; // stick postion
  int steps = 0; // steps
  int dir; // direction

 // This part below of the code I am not sure if it is correct. I have to test
  stickPos = analogRead(A10); // reading stick position 0 to 1023

  if (buttonPos > 520){ 
    if(stickPos > 520 || stickPos < 480);
  steps = (stickPos - 500) / 50; // lower divider will make high speed higher
  }

  //Serial.println(steps);
  delay(4); // larger number of delay will make low speed even slower

  if (steps > 0) dir = 1; else {
    steps = -steps;
    dir = 0;
  }

  digitalWrite(driverDIR5, dir);

  for (; steps > 0; steps--) {
    if (analogRead(A11) > 500) {
      digitalWrite(driverPUL1, HIGH);
      delay(pd);
      digitalWrite(driverPUL1, LOW);
      delay(pd);
    } else {
      digitalWrite(driverPUL5, HIGH);
      delay(pd);
      digitalWrite(driverPUL5, LOW);
      delay(pd);
    }
  }
}

void loop() {
  moveJ1();
  delay(pd);
  moveJ2();
  delay(pd);
  moveJ3();
  delay(pd);
  moveJ4();
  delay(pd);
  moveJ5();
  delay(pd);

}

```

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 22, 2020, 4:33am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/13 "2020-05-22T04:33:25Z")

</div>

The Robot Arm is 6DOF industrial-scale robot created by Chris Annin.

> **[Annin Robotics - open source 6 axis robots you can build yourself](https://www.anninrobotics.com/)**
>
> Annin Robotics -Open source affordable robots - build your own 6 axis robot.

  
Motors specification:  

> **[AR3 Open Source Robot Package Kit - Stepper Motor, Driver, Power Supply and...](https://www.omc-stepperonline.com/ar3-open-source-robot-package-kit-stepper-motor-driver-power-supply-and-bracket.html/?tracking=59c1139e8987b)**
>
> AR3 robot package kit - Stepper Motor, Driver, Power Supply and Bracket - AR3 robot package kit - Stepper Motor, Driver, Power Supply and Bracket - Package including:MotorSKUQuantity J1 motor17HS15-1684S-HG201J2 motor23HS22-2804S-HG501J3...

This is my tinkerswork bench at home :)) I have one lion and pip boy as helpers ; )))) they never complain 😛

 ![20191117_140715](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7f28890bfc5bb640de47bc5ad67c481393282646.jpeg)

 ![20191125_194223](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/ba6a89d4d0f9a4fd2636cb00ecc65cc357899e33.jpeg)

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 22, 2020, 4:38am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/14 "2020-05-22T04:38:17Z")

</div>

[![]( " - YouTube") ](https://www.youtube.com/watch?v=dIJxgbICcFI)

Short video how the program and robot works together:)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 22, 2020, 6:11am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/15 "2020-05-22T06:11:48Z")

</div>

Hello,

Please format your code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

You can go back and edit it.

I am interested but don’t look at code that is not formatted these days.

`:)`

---

<div class="post-metadata">

**Author:** ![Name\_itT](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/name_itt/32/9199_2.png) [@Name\_itT](https://discourse.processing.org/u/Name_itT)\
**Post date:** [May 22, 2020, 7:14am UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/16 "2020-05-22T07:14:33Z")

</div>

Hello  
It didnt give me an error in the post … but I will do check your page and try my best to edit and post it in proper way. Thank u. Have a smile,  
Taniq

ps. I think now it looks much better. ; )

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 22, 2020, 12:18pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/17 "2020-05-22T12:18:34Z")

</div>

> [@Name\_itT](#):
>
> I think now it looks much better. ; )

It does!

I will share more later.

`:)`

---

<div class="post-metadata">

**Author:** ![Shiginet](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@Shiginet](https://discourse.processing.org/u/Shiginet)\
**Post date:** [May 27, 2020, 1:39pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/18 "2020-05-27T13:39:22Z")

</div>

hey!!! I have exactly the same “problem”, i think at the end i will use an serial data connection like: xbox controller - processing - arduinoIDE - stepper motor for the arm… but surely only have the firmdata schetch on the arduino and controlling everything directly from Processing would be much better… did u found at the end the “mystical” stepper library?😉 Or we have do to create our own??

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 27, 2020, 1:53pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/19 "2020-05-27T13:53:01Z")

</div>

Helllo,

I do not use Firmata.

I send serial data from Processing to Arduino, parse it and use that data for control.

[https://www.arduino.cc/en/reference/stepper](https://www.arduino.cc/en/reference/stepper)

`:)`

---

<div class="post-metadata">

**Author:** ![Shiginet](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@Shiginet](https://discourse.processing.org/u/Shiginet)\
**Post date:** [May 27, 2020, 2:25pm UTC](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818/20 "2020-05-27T14:25:53Z")

</div>

ok i will probably do the same… it seems the only solution…Thanks

[Next page](https://discourse.processing.org/t/xbox-controller-stepper-motors/20818.md?page=2)
