Dual Hbridge W/PWM

+ How To Add This Control To Your Project (Click to Expand)
  1. Load the most recent release of ARC.
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Control from the button ribbon bar in ARC.
  4. Choose the Movement Panels category tab.
  5. Press the Dual Hbridge W/PWM icon to add the control to your project.
An H-Bridge is an electronic circuit that enables a voltage to be applied across a motor in either direction. It's triggered by TTL signals from a microcontroller, such as an EZ-B. These circuits are often used in robotics and other applications to allow DC motors to run forward and reverse. A Dual H-Bridge (such as the EZ-Robot 2.5 Amp H-Bridge) controls 2 motors and can be connected to an EZ-B by 6 digital signal wires. 2 wires control each motor, and 2 wires are for PWM. PWM signals control the speed of each motor. This skill controls movement as well as the speed of 2 motors.

This movement panel operates like the other movement panels and can be controlled by scripting or other skills that interact with it. Movement Panels are skills that move your robot forward, reverse, left, and right. The Movement Panel directions can be modified by other skills, such as camera, voice, script, joystick, and radar.

*Note: The I/O ports on an EZ-B cannot provide enough current to directly power a motor. Instead, use an EZ-B to control an H-Bridge that sends power to a motor. Think of the H-Bridge as a worker and the EZ-B as the boss. Also, note that if you don't require PWM speed adjustment you can use the simpler version of this skill here.

Main Window

1. Movement Panel
These buttons will allow you to control the directional movement of the entire robot (left, right, forward, reverse, and stop).

2. PWM Sliders
These sliders control the amount of PWM signal (0-100%) is delivered to the H-Bridge enable pins. *Note: These sliders need to be moved upward in order to activate the PWM signal. The sliders are at 0% (OFF) by default. If you think your H-Bridge isn't working check here first.


1. Title Field
This field contains the title of the Dual H-Bridge w/PWM skill. You can change it if you'd like.

2. Left Motor Control Buttons
These buttons allow you to change the signal and PWM ports for the Left motor.

3. Right Motor Control Buttons
These buttons allow you to change the signal and PWM ports for the Right motor.

Wiring Diagram


1) Connect Dual H-Bridge VCC to either your battery supply positive or EZ-B power (red) on pin D0
2) Connect Dual H-Bridge GND to either your battery supply positive or EZ-B power (black) on pin D0
3) Connect Dual H-Bridge IN1 to EZ-B Signal Pin D0 (white)
4) Connect Dual H-Bridge IN2 to EZ-B Signal Pin D1 (white)
5) Connect Dual H-Bridge IN3 to EZ-B Signal Pin D2 (white)
6) Connect Dual H-Bridge IN4 to EZ-B Signal Pin D3 (white)
7) Connect Dual H-Bridge ENA to EZ-B Signal Pin D4 (white)
8) Connect Dual H-Bridge ENB to EZ-B Signal Pin D5 (white)
9) Connect Dual H-Bridge OUTA to Left Motor Red Wire
10) Connect Dual H-Bridge OUTB to Left Motor Black Wire
11) Connect Dual H-Bridge OUTC to Right Motor Red Wire
12) Connect Dual H-Bridge OUTD to Right Motor Black Wire

*Note: The wiring diagram above depicts powering the Dual H-Bridge off of +V (direct from the input voltage), in this case, the switch onboard the Dual H-Bridge will have to be pushed down. Although, please note that some H-Bridge versions reverse the direction of the switch and it will activate in the up position. You will know if the H-Bridge is on when the power LED on the Dual H-Bridge board lights up.

How to Use Dual H-Bridge w/PWM

1) Physically connect the EZ-B to the Dual H-Bridge using the wiring diagram above as reference. Also, connect motors to the Dual H-bridge.

2) Add the Dual H-Bridge w/PWM Skill to your ARC project (Project -> Add Skill -> Movement Panels -> Dual H-Bridge w/PWM).

3) In the Settings menu select the ports that you connected the H-Bridge's INPUT Pins (D0, D1, D2, D3, D4 & D5 for example).

4) In the main window move the PWM Sliders up to the desired speed.

5) In the main window press the direction buttons to move your robot.

Code Sample

When the EZ-B connection is made, there will be no PWM signal. The PWM signal for this skill is specified by the SetSpeed() command (or PWM sliders). This is usually initialized in your Init script, or in the Connection skill's connection established script.

  • Locate the Connection skill and press the triple dot button.
  • In the Connection skill's scripts tab, locate the 0 - Connection Established Command. This is the script which will execute when the EZ-B Index #0 is connected to an EZ-B. Press the Script Edit button for the Board #0 Established Command.
  • Insert or append the following code and press SAVE to close all dialog windows.

# This sets the speed for the Dual H-Bridge motor controller
# The speed is a number between 0 and 255
# Setting this speed will initialize the PWM on the motor controller




If your robot moves in the reverse direction, or spins instead of going straight, simply reverse the wire connections from the motor to the Dual H-Bridge. If it's too difficult to reach these connection you could also swap the signal sequence around in the skill's Settings menu. Change [D0, D1, D2, D3] to [D1, D0, D2, D3] or [D0, D1, D3, D2] or [D1, D0, D3, D2]. You may need to try a few combinations to get it right. Sometimes it confuses us too!

There is a great community tutorial from Rich that you can find here.

Speed Control
The PWM in the title of this skill means the HBridge will accept a PWM (pulse width modulation) signal from the EZ-B. That is how the EZ-B will control speed of the Dual H-Bridge. As you may recall from the How Servo Works tutorial, you know what PWM is, right? This skill will allow speed adjustments, which gives your project the ability to use joysticks and other skills that manage speed. Read more about how Movement Panels work here .