Skip to content
Sean Ye edited this page May 28, 2017 · 6 revisions

After receiving your h-bridge, break the male header pins so that there's the correct number of pins. Next, take the longer end and place it in the breadboard. Place the chip on top of the shorter pins and solder each pin.

Next, place the chip on the middle of the breadboard and connect it to the teensy according to the following figure. Ensure that mode is pulled to 5 volts for the program below to work.

The code for the h-bridge is located below.

int en1 = 17;
int dir1 = 10;

void setup() {
  pinMode(en1, OUTPUT);
  pinMode(dir1, OUTPUT);
}

void loop() {
  move_motor1(512);
}

void move_motor1(int spd) {
  if (spd >= 0) {
    analogWrite(en1, spd);
    digitalWrite(dir1, HIGH);
  } else if (spd < 0) {
    analogWrite(en1, -spd);
    digitalWrite(dir1, LOW);
  }
}

Clone this wiki locally