I need help to control 2 dc motors with a ps2 analog joystick

I want to control 2 dc motors with the joystick,but i don't know how to mix two pwm outputs for the motors.
here is my initial code

I have a robot with two motors controlled with a joy stick. (You control the robot like an Rc car)

Direction control needs an h-bridge to reverse the polarity on the motor. Can you post a circuit diagram?

My setup it's with an H bridge. Depending on the model the code changes a little.. As jimboZA said post your setup and then we can see what solution is the best. I also have some problems using motors and an H bridge. I'm asking in Starting servo position code needed - Motors, Mechanics, Power and CNC - Arduino Forum this post and then if i have time I will write a post for my blog with the information controlrobotics.rodrigomompo.com

The code seems to use analogWrite with negative values. If you read the arduino reference you will see that you can only write values form 0 to 255 http://arduino.cc/es/Reference/AnalogWrite