Darlington transistor H-Bridge.
Darlington transistor H-Bridge

Build H-Bridge Motor Control Without Fireworks

by Lewis Loflin

Link to YouTube video for this webpage: H-Bridge construction.

This is a shorter version of Safely Build Program a H-Bridge using a MOSFET H-Bridge less focused on programming.

LM317 constant current source.
LM317 constant current source.

The two items above serve the following purposes: limit the current so wiring mistakes or bad programming won't blow your transistors or MOSFETs. The other is simple LED polarity indicator to show the polarity is switching - make sure this works BEFORE connecting a motor!

Make sure any H-bridge is connected to a microcontroller, not push button switches, etc.

Also see LM317 Constant Current Source Circuits

Also see H-Bridge Motor Control 2 Input Diagram.

Below assumes a connection to an Arduino microcontroller.


/*
  Forward-Reverse H-bridge control
 DP2 - Forward
 DP3 - Reverse
 
 DP8 - Q1 PNP PB0
 DP9 - Q2 NPN PB1
 DP10 - Q3 PNP PB2
 DP11 - Q4 NPN PB3
 
 Forward Q1, Q4 ON
 Reverse Q2, Q3 ON
 */

void setup() {
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  digitalWrite(2, HIGH);
  digitalWrite(3, HIGH);
  // DP 8,9,10,11,13 output
  DDRB = DDRB | 0b00101111;  // 4 bytes
  // All off
  PORTB = PORTB & 0x00; // 2 bytes
}

void loop() {

  if (!digitalRead(2))   {
    PORTB = PORTB & 0x00; // off
    delay(500);
    PORTB = PORTB | 0b00101001;
  }

  if (!digitalRead(3))   {
    PORTB = PORTB & 0x00; // off
    delay(500);
    PORTB = PORTB | 0b00000110;
  }
}


See How I got into Electronics

 

PIC16F628A connected to 4 LEDs and 4 switches.

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.