Controlling 2 Motors in a 4-Wheel Robot Using an H-Bridge

Use PWM sliders to control each motor. Values range from -255 (full reverse) to 255 (full forward). When both wheels have the same speed, the robot moves straight (forward/backward). If one wheel spins faster, the robot turns toward the slower wheel.

Forward
200
200

120 px/s
80 px
📘

How It Works

  • Same speed, same direction: Robot moves straight (forward/backward)
  • Left faster than right: Robot turns RIGHT (toward slower wheel)
  • Right faster than left: Robot turns LEFT (toward slower wheel)
  • Opposite directions: Robot spins in place