Control direction + speed with 1 digital and 1 PWM ?

I’m trying to control direction and speed of a small DC motor with a single digital IO pin and a single PWM pin.

I’m interfacing to the motor via a L9110S.
My theory is to use pin 4 (on a Micro) for direction and pin 5 (PWM) for speed.

When pin 4 is LOW I set the speed using various values on the PWM pin between 0 and 255
When pin 5 is HIGH I set the speed using (255 minus the speed value)

However, this does not seem to be working - the motor only travels in one direction (forget which) regardless of what pin 4 is set to.

Am I doing something wrong with the PWM ?
Maybe the L9110S doesn’t like PWM ?

Any thoughts, much appreciated.

… Ken

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

And a link to specs of L9110S

Thanks Tom… :slight_smile:

Thanks Tom,

Image of circuit is attached.
The motor driver board I’m using is one of these : http://www.amazon.co.uk/Microcontroller-L9110S-Stepper-Driver-Module/dp/B00SL0NCRE/ref=sr_1_7?ie=UTF8&qid=1452252657&sr=8-7&keywords=l9110s
Which makes use of 2 of these ICs (datasheet) - L9110S Datasheet

Code to drive the motors is essentially:

void MoveMotor(int joint, int mtr_dir, int spd) {

    int pinA = 0;
    int pinB = 0;
    switch (joint) {
      case 1:
        pinA = baseA;
        pinB = baseB;
        break;

      case 2:
        pinA = shoulderA;  // pin 4
        pinB = shoulderB;  // pin 5
        break;

      case 3:
        pinA = elbowA;
        pinB = elbowB;
        break;

      case 4:
        pinA = wristA;  
        pinB = wristB;
        break;

      case 5:
        pinA = fingerA;  
        pinB = fingerB;
        break;
    }

    digitalWrite(pinA, mtr_dir);

    if (mtr_dir == 1) { spd = 255 - spd; }
    analogWrite(pinB, spd);

}

I was hoping to get away with using just one PWM pin per motor (as I have 5 motors to control, and the Micro only has 5 PWM pins)

Thanks … Ken

Hi,
Have you got the gnd of the arduino connected to the gnd of the driver, if not, you have no reference for the signal levels you are applying to the driver.

Tom..... :slight_smile:

Doh !! :slight_smile:

Works now :slight_smile: Schoolboy mistake…