rhj4:
Would you please share the datasheet you are taking this from?Thanks!
postd the link. just click on 'here' in my previous post! ![]()
Have a look at the truth table, can you see why your code might not work?

one more thing; analogRead does not return the average voltage resulting from the PWM output but the instantaneous value ie either the HIGH or LOW value.
what you could try is something like this in a simple sketch with pre-set 'speed' values to see what happens:
Forward:
digitalWrite(IA, LOW);
analogWrite(IB, speed);
Reverse:
digitalWrite(IB, LOW);
analogWrite(IA, speed);
OR....
Forward:
digitalWrite(IA, LOW);
analogWrite(IB, speed);
Reverse:
digitalWrite(IA, HIGH);
analogWrite(IB, 255-speed); //can you guess why we subtract from 255? ![]()
apologies for the many re-writes of my post... brains working abit slow today! ![]()
