Strange PWM behaviour.

Hi fellows, I have a strange 'problem'. I created a work around, but am still curious what could be the cause!

I'm connecting an H-bridge (L298N) unit (http://www.dfrobot.com/index.php?route=product/product&product_id=66) to my Arduino and use (amongst others) this code:

uint8_t motor1_en = 9;
uint8_t motor1_dir = 8;
uint8_t motor2_en = 11;
uint8_t motor2_dir = 10;

...

digitalWrite(motor2_dir, HIGH);
analogWrite(motor2_en, motorspeed);

I was expecting (ergo: the information from that site has a sketch with that code), that the motors could be set using a value from 0..255 and setting the direction to low and/or high.
But... when I test it using my motor on output 2:
I need to set direction to HIGH and 0 is maximum speed forward, around 100 is minimum speed forward, 125 is about minimum speed backward and 255 is the maximum speed backward. That seems to be quite strange. I don't see any mistakes, I think that I have connected everything well. I know the atmega328 datasheet almost by heart (only 500+ pages ;)).

I bet you have your ENABLE and DIRECTION wires reversed :wink:

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

I also thought about that... Maybe I need to check it again :wink: