XMotion Basics – XMotion 101

XMotion Basics – XMotion 101

What is XMotion?

XMotion is Arduino Compatible all in one robot controller. Which designed specially for robotics, IOT and maker projects.It includes powerful Motor drivers, switching mode regulator, interface circuits and more. With protected features, it is all in one board for lots of different type robot projects.

So in basic, we add sensors, battery, motors and all other blocks are inside XMotion board. With XMotion you can make these robots easily:

  • Mini sumo Robot (500 grams 2- 4 motors)
  • Midi sumo Robot (1 Kg 2-4 motors)
  • Line Follower Robot (Light, fast maneuvering projects)
  • Obstacle Avoiding, Maze Robot
  • Mini Explorer Robots (Up to 3 kg)
  • Bluetooth controlled robots.
  • Light Arm Robots
  • And your imagination.

Topics, we will cover in this article:

  1. How to start
  2. First Code – Blink Led
  3. Adding library
  4. Toggle Leds Example
  5. Motor Control Functions Example
  6. XMotion functions full list
  7. How to use built-in button & dipswitch
  8. How to use Analog input elements (Trimpot & Voltage Sensor)
  9. Motor Selection for XMotion
  10. Battery Selection for XMotion
  11. How to choose sensors & other circuits
  12. How to solder parts to xmotion
  13. Going further, developing projects

1. How to Start

Development with XMotion is very basic, we need to look to right image, back of board. (click the image for bigger size). For your needs xmotion has 8 spare I/O which means you have lots of pins for extra sensors interface circuits. At 8 pins 4 of them is digital and 4 of them is analog. (Remember, you can use analog Inputs also as digital I/O)

Back side table is important, there you can see all I/O usage at board.

When you attach the XMotion with usb cable your computer will alert new hardware found. You can see com port from device manager too.

Let’s try connecting XMotion to computer. We will use micro USB cable for this purpose. XMotion comes with cable but if you need more longer cable, Micro USB type phone cables should work well. Press gently to USB socket.

XMotion will be recognized by computer as an Arduino Leonardo. Sure we are assuming that you downloaded Arduino software (https://www.arduino.cc/en/Main/Software We are choosing windows installer there)

For programming & development with Arduino software, we need to choose port number and board type as Leonardo from tools menu. It must be same as bottom image.

Now please watch the video below for understanding better of board, what parts is used and more.

2. First Code – Blink Led Example

At first example we will blink led. It is the “hello world” of electronics. Please turn the XMotion board and read the pin table you will see there is two User Led definition. D8 and D9. Choose one. I chose D9. D9 is marked as Led2 at XMotion board. (Right upside corner Led2)

Copy/paste or write this code below.

int UserLed1 = 9; //Led Pin is D9
void setup() {
pinMode(UserLed1, OUTPUT); // Led as output element
void loop() {
digitalWrite(UserLed1, HIGH); // turn on the User Led 1, High Statement
delay(500); // wait for half second (500 ms)
digitalWrite(UserLed1, LOW); // turn off the User Led 1, Low Statement
delay(500); // wait for half second (500 ms)

After writing upload with ctrl+u button combination.

If you see led is blinking with 0.5 second intervals. Well done you succesfully uploaded 1st sketch. When uploading due to software based usb connection, interruptions between XMotion and computer can happen. That’s normal.

At XMotion Led1 (Left) is D8, Led 2 (Right) is D9.

3. Adding Library

Now let’s make more advanced coding with XMotion library. You can download the library from here. After downloading xmotion.zip please export directory using arduino software ( Sketch / Include Library / Add ZIP Library)

Restart Arduino software. After reopening Arduino software if library installed, you will see some codes in File / Examples / XMotion (Usually last at Menu)

4. Toggling Leds Example

At this Menu we have 2 options. Open the basics / Blink_2_Leds example. (So full address: Files/Examples/XMotion/Basics/Blink_2_Leds) Code will be only this.

#include <xmotion.h>

void setup() {
void loop() {

With XMotion ready made library. (xmotion.h) we defined the leds before. please upload with ctrl+u. This will give you 1 second interval leds blinking. 2 user led’s will toggle continuously.

5. Motor Control Functions Example

At library we pre-written this Led’s setup functions and pin usages. Now continue to look to example files. You will see Motor Test Code. Now connect 2 dc motors to left and right inputs. For connections you can use green terminals. Later upload the code. Two motor will start to turn.

Toggle Led Example with 2 User Leds at right up corner.

include <xmotion.h>

void setup() {
xmotion.BlinkDelay(100); //Make Blink Both Leds 100 millisecs.

void loop() {
xmotion.Forward(100,100); // %100 Speed, both motor forward 100mS.
xmotion.StopMotors(100); // 100ms Stop Both Motors
xmotion.Backward(70,250); // %70 Speed, both motor backward 250mS.
xmotion.Right0(51,1000); // %51 Speed, 1 second Right 0 Turn.
xmotion.Left0(20,3500); // %20 Speed, 3.5 second Left 0 Turn.
xmotion.ArcTurn(20,60,250); // 250 millisecond %20 Speed Left, %60 Speed Right Motor
xmotion.MotorControl(-150,190); //Timeless -150/255 Left, 190/255 Right Speed
delay(100); //Delay for last MotorControl statement

Motors will start to turn crazy like that below.

Try adding double slash to some motor control functions and upload sketch. Motors will turn according to functions.

6.XMotion Functions

So if I sum up with XMotion functions we make more tidy codes. And here the full list that you can use with xmotion.h library:


  • xmotion.UserLed1(time_ms);
  • xmotion.UserLed2(time_ms);
  • xmotion.ToggleLeds(time_ms);
  • xmotion.CounterLeds(time_ms, int Multiplier);
  • xmotion.Trimpot();
  • xmotion.VoltageIn();
  • xmotion.LipoCutOff(int Cell);

Motor Control:

  • xmotion.Forward(%Percent,Time_ms);
  • xmotion.StopMotors(Time_ms);
  • xmotion.Backward(%Percent,Time_ms);
  • xmotion.Right0(%Percent,Time_ms);
  • xmotion.Left0(%Percent,Time_ms);
  • xmotion.ArcTurn(%LeftPercent,%RightPercent,Time_ms);
  • xmotion.MotorControl(LeftValue,RightValue);

In next lectures we will look more deeply to this functions. Now we must continue to exploring the board.

7.How to use built-in button and dipswitch? Digital Input Elements

XMotion includes 3 position dipswitch and 1 pushbutton. Now we will learn how to use them.

From backside of PCB I am reading button is connected to D10 (start Pin) and dipswitch pins connected to D5, D6, D7.

And as I know they are digital elements, we will look them with digitalRead function. I prepared this code. (Can be found at XMotion examples)

#define DipSwitch1 5 // Dipswitch 1 tied to Digital 5
#define DipSwitch2 6 // Dipswitch 2 tied to Digital 6
#define DipSwitch3 7 // Dipswitch 3 tied to Digital 7
#define Start 10 // Button tied to Digital 10

void setup() {
pinMode(DipSwitch1, INPUT); //Dipswitch 1 Declared as Input
pinMode(DipSwitch2, INPUT); //Dipswitch 2 Declared as Input
pinMode(DipSwitch3, INPUT); //Dipswitch 3 Declared as Input
pinMode(Start, INPUT); //Button Declared as Input

digitalWrite(DipSwitch1, HIGH); // Dipswitch Inputs are High (Pull-up made)
digitalWrite(DipSwitch2, HIGH);
digitalWrite(DipSwitch3, HIGH);

Serial.begin(9600); //Serial Interface started with 9600 bits per sec.

void loop() {
Serial.print(“Button State:”); //We are writing this statement to serial Monitor
Serial.print(digitalRead(Start)); //digital reading of button
Serial.print(” “);
Serial.print(“Dipswitch Inputs:”);
Serial.print(digitalRead(DipSwitch1)); // digital reading of dipswitches

Dipswitch is used mostly at mini sumo robots for starting modes. And also used for on-board software development.

Start button connected to D10 is used for giving starting signal.

After uploading code, don’t remove the USB cable and click the serial monitor. (Right up corner at Arduino editor) XMotion will start to send some values to computer.

With this code you can see what’s going on at dipswitch and button. Button gives logic 0 when not pushed. And dipswith inputs give logic 1 when they are at down.

And if you want to use at the code we use them with if, while statements like these:

if (digitalRead(DipSwitch1)==1) {Kp=0.30;} else {Kp=0.35;}

while(digitalRead(Start)==0) {MotorControl(0,0); digitalWrite(Led1, HIGH); digitalWrite(Led2, HIGH);}

These are 2 examples…

8.How to use Analog Input Elements, Trimpot & Voltage Sensor

We are contiune to learn features of XMotion controller. XMotion includes one trimpot (connected to A3 pin) and one voltage divider resistor group (connected to A0 pin).

This analog elements can be read directly with analogRead function of Arduino language. But better than analogRead we have two functions:

  • xmotion.Trimpot();
  • xmotion.VoltageIn();

Now please open the example file at File/Examples/XMotion/basics/Trimpot_to_Led sketch.

#include <xmotion.h>

void setup() {


void loop() {
xmotion.BlinkDelay(xmotion.Trimpot()); //Blink delay in trimpot between 0 – 1023 milliseconds.

With this code you will change User Leds toggling time from 0ms to 1023 milliseconds. xmotion.Trimpot(); function gives value from 0 to 1023.

And another example, voltage divider (voltage sensor) you can use this feature for sensing input voltage (i.e battery voltage). When battery voltage drops below limit you may stop xmotion working for not damaging battery. (Mainly used for LiPo batteries).

This example will give input voltage.

9.Motor Selection for XMotion

All small motors can be used with XMotion usually but lets make more spesific.

If motor’s stall current is lower than 6 ampere and working voltage is lower than 24V it can be used. So for instance 12V stall 1 amper motor can be used perfectly. But 24V 5 amper motor shouldn’t be used. First example is 12 watts max power, where as other is 120 ampere. If you are going to use high current motor model use 2 or 3S battery. If it is low current motor, go up to 24V. With XMotion we tested these models successfully.

  • JSumo 15mm Core Series.
  • JSumo 16mm Profast Series.
  • JSumo 12mm All Series.
  • Fingertech 16mm Spark Series
  • Pololu 12mm HP & normal series
  • Pololu 20 and 25mm Gearmotor series.
  • JSumo 25mm Dc Gearmotor series
  • JSumo Titan 37mm Series (HP models work but not recommended due to higher stall currents)

As you can see from the list nearly all small motors can be used. If motors draw higher current at starting (At start motor nearly draw stall currents, be carefull) motor drivers can close itself. You need to close/open the power switch. If this happens remove the motor cables from xmotion and look to motor driver leds. If they don’t light, motor driver has a problem. If they light but when you attach motor they turn off, motor needs higher current than XMotion give or motor is broken 🙂 Easy 🙂

Motor output holes have different size pitch pads for easy connection. You can use directly soldering, or use green terminals that included with XMotion.

10.Battery Selection for XMotion

We suggest 2S to 4S Lipo batteries. Usually we are using 3S small (350 to 1000 mah) batteries with no problem. Sure higher capacity batteries can be used. If your robot resets suddenly, or performancing poorly first look to battery voltage. 2S battery full charge is 8.4V, %20 nearly finished charge is 7.4Volts. 3S battery full charge is 12.6V, %20 charge is 11.1 Volts.

Always store them charged. And for low voltage alarm you can use xmotion.h libarary’s xmotion.VoltageIn(); and xmotion.LipoCutOff(int Cell); functions. LipoCutOff function looks to battery voltage according to cell count that we wrote inside paranthesis and if unit cell voltage is lower than 3.6V it stops the code and giving alarm with toggling leds.

Battery voltage directly goes to motor driver blocks inside XMotion. So if you need more speed, torque at robot. Try increasing battery voltage. Among robot makers overvoltaging motors for more juice is very common.

At this issue also I want to clarify one thing wrongly known at beginners rookies, they think if they use higher current capacity battery they can burn the board, robot. This is not true, you can use 100.000 mah battery within voltage limits. This capacity value only determines that how much current it can give total. If your robot draws few miliampers still it takes few milliampers at any capacity battery.

Battery input holes have different size pitch pads for easy connection.

11.How to Choose Sensors & Other Circuits for using with XMotion?

All sensors that can be used with Arduino Uno and Leonardo boards also suitable to XMotion. Moreover you can use servo motors with XMotion, it is more current giving capable than Uno boards with 500 milliamps switching mode power supply inside XMotion. (Arduino Uno has 200ma limited, linear regulator).

You can directly solder HC06 Bluetooth module with bottom solder pads at center. (We will have example page soon)

At this project we attached standard Radio Control Receiver to XMotion pins. Controller drives 6 gear motoe with remote.

XMotion gives 5V to I/O terminals. So if your sensor is not working with 5V it won’t work with XMotion. Or another option you can use high voltage directly from Voltage input terminal (At some minisumo projects we use 12V Omron sensors and taking power directly from battery input) And at inputs main mcu (Atmega32u4) is semi protected with 220 ohm resistors (still better than no resistor, uno, nano boards)

Ultrasonics sensors, RF modules, bluetooth modules, extra motor driver, breakout boards will work with xmotion with no problem.

12.How to Solder other parts to XMotion?

At bottom side you will see the small solder pads for attaching sensors and other interface circuits. If you plan the swap controller with other robot projects. just solder male headers and use female cables or pins for attaching. The header pads have standard 0.1 inch (2.54mm) spaces.

If you determined directly soldering, here the tips. First add small drop of solder to pads. Later only strip 1 mm insulation, not more. If you strip more it can cause short circuits. We don’t want this. And before soldering be careful to polarity of sensors and make sure that sensor works. Here one example of our mini sumo robots. 8 I/O all of them is used.

This is how you should make solder connections.

Here the mini sumo robot model XMotion Advanced Minisumo with 5 opponent sensors, 3 line sensors and 3 Core 6V 300 Rpm motors with 12.6V (3S) lipo battery. Advanced kit comes with advanced soldering.

Another example with female jumper wires.

14.Developing the Projects

XMotion gives you extra complementary elements for development projects. Some examples

  • Use the trimpot for controlling speed at line follower robot.
  • Use the 3 slide Dipswitch for total 8 (2^3) starting combinations at mini sumo robot.
  • Attach bluetooth module to bottom side of XMotion pins. Use it as a debug and control via phone.
  • Use 2 user leds for sensor test, debug routines.
  • Use voltage divider resistor input for measuring battery voltage and correlate robot speed with battery voltage.
  • Start the robot with built-in button or with extra start module with attaching start input.

My last words for this article is make everything step by step. First try turning on,of lights, later motor controlling later if statements for loops. And later combine all blocks. But don’t make anything fast. Again I am saying one by one. 🙂


  1. Reply

    Hello eberyone, hello jsumo team, how are you guys.

    I have contacted you because i have a problem with the code of my sumo robot black magic that i bought a few weeks ago. I dowloaded the basic sumo robot code from the xmotion libary that is on your xmotion/dropbox page.
    The problem is , when i pút the code in the xmotion card, it runs, but the robot runs in circles, he does not detect the white line, and he goes forward only with the right motor, because with the left motor It goes a little foward and stops, forward and stops.
    I have already read the code and i dont really get in what part of the code the sumo robot does this.
    Please help me and contact me as fast as you can , because i need the robot working, in a couple of days.
    I would be so happy if you could help me with this problem as soon as possible!
    Thank you, have a great day!

    • Reply

      Hello friend, actually code is written very clearly. Maybe there is one sensor connection problem. We always suggest testing at first hand. So we can understand what is going with dohyo.
      Can you try with writing only forward motors routine?

  2. Reply

    pleas, can you sent me program xmotion

  3. Reply


    I have a question regarding the XMotion board, can I use I2C sensor like the VL6180X TOF sensor?
    Thank you

    • Reply

      In new models, we have option to attach I2C sensors with modifying inputs. But it needs little work sir. At old boards unfortunately we don’t have. For understanding about your board is modifiable you need to find if ledt motor driver has extra pad written D3/SCL. If it has you can swap I2C pins from motor driver pins.

    • Reply

      Re-bonjour, j’ai pu télécharger le zip que vous avez envoyé et je vous remercie.
      Mais j’ai un autre problème, il manque des fonctions tels que “BlinkDelays” et “Délai de vitesse (100); //Délai pour la dernière instruction MotorControl” qui sont présentés dans l’étape “5.Exemple de fonction de commande de moteur”

  4. Reply

    hola tengo un problema con el switch no estaba cogiendo al momento de deslizarlo, quiero cambiarlo pero no se si la los pines que estan cortados deben de hacer contacto con la parte smd, solo 3 pines son true hold como sueldo un reemplazo?

    • Reply

      You can directly solder together all 6 pins bottom (or 3 pins side by side). And attach switch outside, it would be more easy to solution.

  5. Reply

    I want to make an RC type sumo robot using Xmotion.
    I want a sample program.

  6. Reply

    Have you delivery for Uzbekistan

    • Reply

      Yes we ship to all over the world. We have options to choose different shipment methods at jsumo.com

  7. Reply

    When will the xmotion mega restocked?

    • Reply

      Due to the global chip crisis, we have production problems mainly lack of motor driver ICs, unfortunately, we are making some updates, but it will take a minimum of 4-6 weeks.

      • Reply

        Hey, thanks for the reply. I was wondering if you can give me some sumo wheels recommendation. I’m planning on making a 3kg yokozuna style (slow & powerful) sumo robot with a vacuum pump. The vacuum pump itself gives a downforce around 10-15kg, and moving the robot will require at least 6-10kg moving/pushing force to move. Which type of wheel is suitable for my application?

        I appreciate any type of reply.
        Thank You.

        • Reply

          These forces are very low when compared with magnetic type japan sumo robots. Vacuum pumps are tried loong years ago but not effective as neodmiyum magnets. Is that sumo robot tournament uses steel ring and magnet usage allowed or not?

          • The majority of sumo tournaments around my area uses non metallic ring and the majority of the competitor uses non magnetic robot. That’s why I see the opportunity of using vacuum because no one ever did (around my area). I think vacuum will be a big advantage for me.

  8. Reply

    merhabalar bana 5 adet kızılötesi verici modülü ile kullanılmış labirent robotu örnek kodu atabilir misiniz böyle bir projem var fakat elimde örnek kod yok yardımcı olursanız sevinirim

  9. Reply

    I ran the right0 and left0 functions on the Mini Sumo Robot, but in both cases the motors do not rotate in reverse. For reverse commands, the motor rotates in reverse.

    • Reply

      Thank you sir, we will control the library upcoming days. I guess there is a bug at code or somehow pin decleration missing. We will solve and inform you.

  10. Reply

    Are you limiting the DIR of the circuit? Alternation is not possible.

    • Reply

      Sorry but I didn’t understand about limiting DIR, Dir is used for direction control of motors.

  11. Reply

    Bluetooth modülü ile kod yükleyebilir miyiz? Kablo sök tak yapmaktan bağlantı noktası kırılıyor.

    • Reply

      Maalesef, ana işlemcinin Atmel 32u4 olması nedeniyle bluetooth/uart üzerinden kod yüklenememektedir. Arduino Nano kullanan Genesis kartımızda bluetooth üzerinden yükleme yapabiliyoruz. Yakında örneği paylaşacağız. Ek olarak XMotion kartı 2023 versiyonunda mikro usb soketi 2 pin yerine 4 pinli kullanılmıştır, biraz daha dirençlidir.

  12. Reply

    Hello? I can’t load the library. Link removed

    • Reply

      • Reply

        Im getting an error when trying to add this library as a zip file.
        Error: 13 INTERNAL: Library install failed: moving extracted archive to destination dir: library not valid
        would you happen to know what this means? Im using a school computer and the latest version of Arduino IDE (2.0.4).

        • Reply

          Hmm.. Maybe it is because the library and zip folder name are not the same. Can you try updating it as xmotion.zip? If not, can you manually extract & copy the zip folder into documents/Arduino/libraries? When the Arduino software restarted again, the xmotion library should come in file/example menu.

  13. Reply

    buenos dias, me podria compartir el manual de la tarjeta en pdf, no se que pines son el tx o rx

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>