HG7881 Don't Work

Hi to all :slight_smile:

I’m trying to make to work a DC Motor with my arduino pro mini through an hg7881 motor controller but don’t work :C

actually i made the conections as the image attached and i use this code made by @manic9 here

int MOTOR_A_PWM = 6;
int MOTOR_A_DIR = 5;
char data;

void setup()
  Serial.begin( 9600 );
  pinMode( MOTOR_A_DIR, OUTPUT );
  pinMode( MOTOR_A_PWM, OUTPUT );
  digitalWrite( MOTOR_A_DIR, LOW );
  analogWrite( MOTOR_A_PWM, LOW );
void loop() {
  if (Serial.available() ) {
    if (data=='1'){
       digitalWrite(MOTOR_A_DIR, HIGH);
      analogWrite(MOTOR_A_PWM, 100);
    if (data=='2') {
       digitalWrite(MOTOR_A_DIR, LOW);
      digitalWrite(MOTOR_A_PWM, LOW);

even i use a duemilanove without sucess

Can somebody give some orientation to find a solution?

I suspect you need to connect the Arduino's and the controller's grounds together;

@JimboZA Thanks a lot for your guidance, first tried whith a duemilanove and later with the pro mini and works as a charm!

You're welcome.

Do you see why it's necessary? The signals from the Arduino are at 5V, but that 5V only has meaning if measured against a reference. So the Arduino side "knew" they were 5V, since they have the Arduino Gnd to measure against. But as far as the controller end was concerned, there was no 0V until you hooked the grounds together and so the connection was really just some random bit of wire.

It's a bit like trying to measure the voltage of a battery by only sticking the red lead on the +ve cap and not touching the black to the other end.....