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