BTS 7960 43a motor driver code for Bluetooth control

hi

im doing a project on a RC car and im using the bt_2 (BTS 7960) h bridge module with 12 power source of 12 v and 4 amps !

i want to control the motor by bluetooth and i have the hc-06 ! forward and reverse

any ideas of working this together !!

this is the code that i tried but doesnt work

int motorPin1 = 3;
int motorPin2 = 4;
int enablePin = 5;

int state;
int flag=0;

void setup() {

pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(enablePin, OUTPUT);

digitalWrite(enablePin, HIGH);

Serial.begin(9600);
}

void loop() {

if(Serial.available() > 0){
state = Serial.read();
flag=0;
}

if (state == '0') {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
if(flag == 0){
Serial.println("Motor: off");
flag=1;
}
}

else if (state == '1') {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
if(flag == 0){
Serial.println("Motor: right");
flag=1;
}
}

else if (state == '2')
{
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
if(flag == 0){
Serial.println("Motor: left");
flag=1;
}
}
}

thanks

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor.

What exactly do you mean by "doesnt work " ?

What tests have you carried out to try and figure out the problem?

Make a pencil drawing showing how everything is connected and post a photo of the drawing.

Post a link to the datasheet for your h-bridge.

How are you powering the motor and the Arduino?

...R

You probably should use the analog write method to operate the H-bridge. Check the BTS7960 data sheet on the requirements. The below discussion may have some info.

http://forum.arduino.cc/index.php?topic=148482.0