24 de febrero de 2015

Control de motores con el módulo L9110s dual y Arduino

Controlador de motores DC y stepper motors.
HG7881

Conexiones con arduino:
L9110s               arduino
  B-IA     ----------    D5
  B-IB      ----------   D6
  VCC     ----------   +5v
  GND    ----------    gnd
  A-IA    ----------    D3
  A-IB    ----------    D4

  MOTOR A  === Motor A
  MOTOR B  === Motor B

Code arduino:
//----------------------------------------------------------------------
const int AIA = 3;
const int AIB = 4;
const int BIA = 5;
const int BIB = 6;
byte speed = 255;

void setup() {
   pinMode(AIA, OUTPUT);
   pinMode(AIB, OUTPUT);
   pinMode(BIA, OUTPUT);
   pinMode(BIB, OUTPUT);
 }

void loop() {
  forward();
  delay(2000);
  backward();
  delay(2000);
}

void backward() {
  analogWrite(AIA, 0);
  analogWrite(AIB, speed);
  analogWrite(BIA, 0);
  analogWrite(BIB, speed);
}

void forward() {
  analogWrite(AIA, speed);
  analogWrite(AIB, 0);
  analogWrite(BIA, speed);
  analogWrite(BIB, 0);
}

//----------------------------------------------------------------------


Ref.:
http://me.web2.ncut.edu.tw/ezfiles/39/1039/img/617/L9110_2_CHANNEL_MOTOR_DRIVER.pdf
http://www.dx.com/es/p/hg7881-two-channel-motor-driver-board-blue-green-black-2-5-12v-2157

No hay comentarios:

Publicar un comentario