Basically I have a motor control board which connects motors and Inputs connected to an arduino.
Which motor controller board?
int IN1 = 6;
int IN2 = 5;
int IN3 = 9;
int IN4 = 10;
Don't some of these control direction and some control speed? Wouldn't it be useful if the names reflected that fact?
I am trying to create method for moving forward and backward.
You have one method called forward(). Where is the backward() one?
//M1 CW=01 CCW=10
analogWrite(IN1, 150);
analogWrite(IN2, 0);
//M2 CW=01 CCW=10
analogWrite(IN3, 160);
analogWrite(IN4, 0);
The values for CW and CCW shown do not look right. It's hard to know which of the names correspond to direction pins and which correspond to speed pins.
But it doesn't work and I'm new programming so hope someone can point out my mistake.
Sure. You didn't tell us what does happen when that code runs.