Myo Gesture Armband icon Myo Gesture Armband — Map Myo armband gestures and accelerometer to servos and ARC scripts for arm-mimic control; supports multiple armbands. Try it →
 
Balance Robot

Balance Robot by Sain

Synthiam ARC balances, tunes, and drives the SainSmart Upright Rover v3 with live PID, scripts, joysticks, and AI.
Connection Type
USB
Number of Servos
None
Audio Support
No
Camera Support
No
UARTs
None
I2C Support
No
ADC Ports
None
Digital Ports
None
A two-wheeled self-balancing robot with stacked circuit boards standing upright beside a laptop showing a live tilt graph, a side-view gauge and tuning sliders
Balance Robot + Synthiam ARCx & ARC

Make a two-wheeled robot balance, drive and learn

The SainSmart InstaBots Upright Rover v3 is a self-balancing robot built on an Arduino Mega and an MPU6050 motion sensor. With Synthiam firmware on the Mega, you can tune its balance live, drive it like any other robot, and add it to scripts, joysticks and AI.

How this robot works with Synthiam. The robot's Arduino Mega runs Synthiam firmware that does the balancing itself, and a movement panel robot skill talks to it over USB or Bluetooth serial. There are two ways to do it. The original approach uses the EZ-Mega v1 Balance Robot firmware written for this kit with ARC's Inverted Pendulum skill. The newer approach uses ARCx's Two Wheel Self Balancing Robot skill and its own firmware, which supports the same kind of hardware (Arduino Mega, MPU6050, an IN1/IN2/PWM motor driver and encoder motors) after a one-time pin edit, and adds an auto-tuner and EEPROM-saved settings. For a new build we recommend ARCx; the ARC firmware is the one made and shown working on this exact kit.

Meet the robot

What is a balance robot?

A balance robot is an inverted pendulum: it stands upright on two wheels, the way you balance a broom on your hand. To stay standing it constantly reads its tilt angle with an IMU sensor and speeds the motors up or down to drive the wheels back under its body.

The SainSmart InstaBots Upright Rover v3 kit provides the hardware: an Arduino Mega, an MPU6050 IMU, a dual motor driver and two gear motors with wheel encoders. Synthiam's firmware replaces the kit's own sketch so Synthiam can talk to the robot, drive it and adjust its tuning.

Perfect balance takes patience, because the PID values (the numbers that decide how strongly the robot corrects itself when it leans) need tuning for each robot. ARC lets you adjust them with sliders; ARCx can also find them for you with its auto-tuner.

Balance Robot at a glance

TypeTwo-wheeled self-balancing robot kit
MakerSainSmart (InstaBots Upright Rover v3)
ControllerArduino Mega
IMUMPU6050
MotorsTwo DC gear motors with wheel encoders, dual H-bridge driver
ConnectionUSB (115200 baud) or a Bluetooth serial module
Synthiam uses it forA balancing robot base driven and tuned from Synthiam
Websitesainsmart.com (listed as discontinued)
Choose your approach

Two firmware options for the same robot

⚖

ARC + EZ-Mega v1 Balance Robot firmware

  • Written for the SainSmart Upright Rover rev. 3.0; the pins are already right.
  • The ARC Inverted Pendulum skill sets Kp, Ki and Kd with sliders, corrects the balance angle, drives the robot and sends a calibrate command.
  • Shows Kp, Ki, Kd, omega, angle, distance, encoder values, angle offset and speed live.
  • Windows only. The skill is described as beta.
🚀

ARCx + Two Wheel Self Balancing Robot firmware

  • One sketch for Arduino Uno, Nano, Mega or ESP32. Set the motor driver type and pins once in section 1; no extra libraries.
  • Every PID gain, the balance point, speed limits, motor and encoder directions and IMU orientation are set live from ARCx and saved to the robot's EEPROM.
  • An auto-tuner finds the gains on the floor in a few minutes.
  • Keeps balancing if the link drops. Windows, Linux and Raspberry Pi, used from any browser.
The original approach

Set up the robot with ARC

What you need

  • A SainSmart v3 Balance Robot kit (or equivalent hardware), with its Arduino Mega and MPU6050 IMU shield
  • A Windows PC with Synthiam ARC installed
  • A USB cable for the Arduino Mega (recommended for first-time setup)
  • Optional: a compatible Bluetooth serial module for wireless control
  1. Download the firmware source. Download EZ-Mega v1 Balance Robot Sourcecode
    Source package date: Feb 4, 2019.
  2. Compile and upload it to the Mega. Follow the tutorial to compile the source code and upload the firmware to the SainSmart Mega Arduino. You need the Arduino IDE (or the toolchain the tutorial describes). Uploading firmware is how the Arduino is programmed.
  3. Add the movement skill in ARC. Add the Inverted Pendulum skill. It sends balancing and movement commands to the firmware on the Mega.
  4. Connect and tune. Select the COM port and connect. Adjust Kp first, then Kd, then Ki: Kp is usually the larger value and Kd very low. Use the angle correction slider if the robot creeps one way.

Beginner tip: start with USB. It is simpler, more reliable and easier to troubleshoot than Bluetooth.

Common beginner issue: if ARC cannot connect over USB, double-check the COM port selected in ARC, and that no other program (like the Arduino IDE Serial Monitor) is using that port. The Mega has one USB port, so the Serial Monitor and ARC cannot connect at the same time.

Connection reference

USB or Bluetooth with the EZ-Mega v1 firmware

At the top of the firmware source is a small configuration section where you choose which serial port to use and the baud rate. ARC must be set to the same baud rate.

Mega portPinsUse
SerialUSBRecommended. 115200 baud over the Arduino's built-in USB connection.
Serial119 (RX), 18 (TX)Do not use. Pin 18 is used by a wheel encoder in this robot, so Serial1 would conflict and make balancing unreliable.
Serial216 (RX2), 17 (TX2)Recommended for a Bluetooth module. 9600 baud, or whatever your module is set to.
Serial315 (RX), 14 (TX)Available.

Use this when the Arduino Mega is plugged into the PC with a USB cable. The best option for beginners.

// The communication baud rate
#define _BAUD_RATE 115200

// The primary communication interface between ARC and this controller
// Serial  - USB (recommended 115200 baud)
// Serial1 - 19(RX), 18(TX) <- do not use because pin 18 is used by wheel encoder
// Serial2 - 16(RX), 17(TX) <- recommended for bluetooth dongle
// Serial3 - 15(RX), 14(TX)
#define COMMUNICATION_PORT Serial

Bluetooth on Serial2 at 9600 (optional)

Use this with a Bluetooth serial module wired to the Mega's Serial2 pins. The baud rate must match the module's setting. TX always goes to RX: Mega TX2 (pin 17) to the module's RX, Mega RX2 (pin 16) to the module's TX.

// The communication baud rate
#define _BAUD_RATE 9600

// The primary communication interface between ARC and this controller
// Serial  - USB (recommended 115200 baud)
// Serial1 - 19(RX), 18(TX) <- do not use because pin 18 is used by wheel encoder
// Serial2 - 16(RX), 17(TX) <- recommended for bluetooth dongle
// Serial3 - 15(RX), 14(TX)
#define COMMUNICATION_PORT Serial2
The newer approach

Use the robot with ARCx

The ARCx Two Wheel Self Balancing Robot skill comes with its own firmware, downloaded from the skill's Firmware tab with a README. It balances 200 times a second on the Mega, and ARCx drives it, shows what it is doing, tunes it live and saves the tuning into the robot.

Pins for the Upright Rover

The firmware's default Mega pins are not the Upright Rover's. These are the pins the original EZ-Mega v1 firmware uses on this kit; enter them in section 1 of the ARCx sketch with MOTOR_DRIVER set to DRIVER_IN1_IN2_PWM.

SignalMega pinARCx sketch setting
Left motor direction23, 22LEFT_IN1_PIN, LEFT_IN2_PIN
Left motor speed (ENA)5LEFT_PWM_PIN
Right motor direction24, 25RIGHT_IN1_PIN, RIGHT_IN2_PIN
Right motor speed (ENB)4RIGHT_PWM_PIN
Encoder, one wheel19 (interrupt), 18..._ENC_A_PIN, ..._ENC_B_PIN
Encoder, other wheel3 (interrupt), 2..._ENC_A_PIN, ..._ENC_B_PIN
MPU605020 (SDA), 21 (SCL)Picked by the Wire library
Motor driver standbyNot used by the original firmwareMOTOR_STANDBY_PIN -1
Battery dividerNot used by the original firmwareBATTERY_PIN -1 unless you add one

The original firmware's comments do not make clear which encoder belongs to which wheel. If the Robot tab's wheel test counts on the wrong wheel, swap the left and right encoder pins.

  1. Edit and upload the sketch. Set the pins above, pick the Mega and its port in the Arduino IDE, upload, and close the Serial Monitor.
  2. Add the skill in ARCx from Robot Skills, Movement Panels, choose the COM port and leave DTR off (raising DTR resets the Mega, and the robot falls every time ARCx connects).
  3. Check the hardware on the Robot tab, in order: IMU orientation (Upright, then Tilted forward), each wheel's motor and encoder direction with the wheels lifted, encoder counts per wheel turn and wheel diameter.
  4. Auto-tune on the floor and stay with the robot: it tells you when to hold it, let go and stand it back up. Then Use these values, Save, and Save to robot.
  5. Drive it with the direction buttons, a joystick, scripts or the Custom UI.
The Auto-tune tab of the ARCx Two Wheel Self Balancing Robot skill with the tuned values beside the old ones and a list of every trial
A finished auto-tune: the result beside the values from before, and every trial with its lean error, shaking, wobble and speed error.

The auto-tuner runs four steps:

  1. Drop test: the robot falls with its motors off; how fast it falls sets the ratio of Angle KD to Angle KP.
  2. Balance gain search: Angle KP is raised until the robot shakes and lowered until it gets sloppy; the middle of the range is chosen.
  3. Balance point: the robot's average lean standing still.
  4. Speed loop: the robot drives about half a meter each way while Speed KP is tuned.

The robot's lean, speed, distance, battery and state are published as variables such as $BalanceLean and $BalanceIsBalancing.

First balance

After you connect

Safety

  • Place the robot on a safe surface: start on the floor, not a table.
  • Be ready to catch it. Early PID values may make it jerk or fall.
  • A balancing robot can suddenly accelerate while tuning. Keep hands, cables and loose clothing away from the wheels.

Reading the robot

  • Shakes rapidly or drives away at once: adjust the PID tuning and check the motor directions.
  • Falls the same way every time: the IMU orientation, a motor or an encoder is backwards.
  • Creeps one way while standing: the balance point (angle offset) is wrong.
  • Buzzes: too much KD, or a loose IMU.
ARCx or ARC?

Which one should I use?

ARCx + Two Wheel Self Balancing Robot Recommended ARC + Inverted Pendulum
Runs onWindows 10/11 x64, Ubuntu 24.04 x64 and ARM64, Raspberry PiWindows
Firmware for this kitGeneric sketch; enter the Upright Rover pins onceEZ-Mega v1, written for this kit
TuningLive gains, auto-tuner, saved to the robot's EEPROMKp, Ki, Kd and angle offset sliders
Balances without the PCYes, with the saved tuningUses the firmware's built-in gains until ARC sends new ones
LinksUSB, Bluetooth serial, ESP32 Wi-Fi, serial bridge, EZB UARTUSB or Bluetooth serial
Tested on this kitNot yetYes (see the video)

ARCx is Synthiam's newer platform: it runs headless on the robot's computer or any PC, is used from any web browser by several people at once, and lets AI agents drive and program the robot through MCP.

Help

Troubleshooting

Check the COM port, and close the Arduino IDE Serial Monitor or anything else using the port. Make sure the baud rate in the firmware matches the skill (115200 over USB). In ARC, connecting with the wrong firmware loaded reports a capability error: upload the EZ-Mega v1 Balance Robot firmware.

Check TX goes to RX both ways (Mega TX2 pin 17 to the module's RX, RX2 pin 16 to its TX), that COMMUNICATION_PORT is Serial2, and that the firmware baud rate matches the module's. Do not use Serial1: pin 18 is a wheel encoder.

Leave DTR off in the Connection settings. Raising DTR resets an Arduino Mega, Uno or Nano.

A robot that runs away when driving needs more Angle KI. A robot that rocks slowly with its wheels still needs some motor deadband. Heavy batteries mounted high make a robot easier to balance, not harder: it falls more slowly.

Disconnect Synthiam first so the IDE can use the port. In ARCx, press Disconnect in the skill before uploading new firmware.
Questions

Frequently asked questions

SainSmart lists its InstaBots self-balancing robot as discontinued. If you are building a new balance robot, the ARCx firmware runs on an Arduino Uno, Nano, Mega or ESP32 with an MPU6050, a common motor driver (TB6612FNG, L298N, DRV8833 and others) and two gear motors, ideally with encoders.

No. With both firmwares the balancing runs on the Mega; Synthiam drives and tunes it. With the ARCx firmware the robot keeps balancing if the link drops, stops driving when drive commands stop, and can balance at power up with the tuning saved in its EEPROM.

Yes. The balancing skill is a movement panel, so a camera on the computer, tracking skills, speech recognition, joysticks and scripts all drive the robot the same way they drive any Synthiam robot.

Get your robot balancing

Flash the firmware, add the balancing skill, and tune, drive and program your two-wheeled robot.


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

#1   — Edited

I assume the communication is going through a ESP8266 on the bot? Contacted the company to purchase one of the shields (to build myself) but was told it was discontinued:( You must have to buy the whole bot from them now.

Thanks in advance.

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#2  

Yeah - we should be able to recreate the same build with DIY parts. The shield is merely an HBridge, but you can use any hbridge (specifically the EZ-Robot one). The IMU it uses is the MPU6050.

As for wireless... I'm actually using a Bluetooth <-> UART module. The same ones that were on the EZ-B v3.