How to control DC Motor using HG7881/L9110 with Arduino




HG7881 (Another version of the L9110 motor driver) Dual Channel Motor Driver Module is a compact board that can be used to drive a small robots. This tiny module has two independent HG7881 motor driver chips which can each drive up 800mA of continuous current. 2.5V to 12V able to enabling this module to be used with both 3.3V and 5V microcontrollers.


schematic diagram




Hardware
-Arduino board
- HG7881/L9110 Driver board
- Jumper wires
- DC Motor x2
- External power supply 2.5v to 12v

Arduino sketch


const int motorA1 =  6;
const int motorA2  = 7;
const int motorB1 =  8;
const int motorB2 =  9;

void setup() {
  // put your setup code here, to run once:
  pinMode( motorA1 , OUTPUT);
  pinMode( motorA2 , OUTPUT);

  pinMode( motorB1 , OUTPUT);
  pinMode( motorB2 , OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite( motorA1 , HIGH);
  digitalWrite( motorA2 , LOW);

  digitalWrite( motorB1 , HIGH);
  digitalWrite( motorB2 , LOW);

  delay(5000);
  // stop
  digitalWrite( motorA1 , LOW);
  digitalWrite( motorA2 , LOW);

  digitalWrite( motorB1 , LOW);
  digitalWrite( motorB2 , LOW);

  delay(3000);

  digitalWrite( motorA1 , LOW);
  digitalWrite( motorA2 , HIGH);

  digitalWrite( motorB1 , LOW);
  digitalWrite( motorB2 , HIGH);

  delay(5000);
  // stop
  digitalWrite( motorA1 , LOW);
  digitalWrite( motorA2 , LOW);

  digitalWrite( motorB1 , LOW);
  digitalWrite( motorB2 , LOW);

  delay(3000);
  
}


ความคิดเห็น