I followed this tutorial: enter link description here
I built it according to the schematic except I didn't connect an LED (I assume this isn't the problem). This is the schematic:
I'm a beginner so at first I connected the TX and RX of the HC-05 and the UNO but after getting errors I unplugged them from the UNO, uploaded the code, then plugged them back in (is this correct?)
This is the code that I uploaded to my UNO:
char t;
void setup() {
pinMode(13,OUTPUT); //left motors forward
pinMode(12,OUTPUT); //left motors reverse
pinMode(11,OUTPUT); //right motors forward
pinMode(10,OUTPUT); //right motors reverse
pinMode(9,OUTPUT); //Led
Serial.begin(9600);
}
void loop() {
if(Serial.available()){
t = Serial.read();
Serial.println(t);
}
if(t == 'F'){ //move forward(all motors rotate in forward direction)
digitalWrite(13,HIGH);
digitalWrite(11,HIGH);
}
else if(t == 'G'){ //move reverse (all motors rotate in reverse direction)
digitalWrite(12,HIGH);
digitalWrite(10,HIGH);
}
else if(t == 'L'){ //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)
digitalWrite(11,HIGH);
}
else if(t == 'R'){ //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)
digitalWrite(13,HIGH);
}
else if(t == 'W'){ //turn led on or off)
digitalWrite(9,HIGH);
}
else if(t == 'w'){
digitalWrite(9,LOW);
}
else if(t == 'S'){ //STOP (all motors stop)
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
}
delay(100);
}
Then I paired with the HC-05 and used the ArduinoCar app which works as follows: if I press forward it will send 'F' if I press backward it will send 'G' and so on. I successfully connected to HC-05. However when I press forward, the motors don't move this goes for all the other directions. The thing is when I press forward, for example, the UNO lights up (the L and TX LEDs light up) so I'm pretty sure it's getting received by the UNO but something is still wrong...
edit: I got it to work by powering the L298n (9V) and the UNO (rn connected to computer) separately and now the right and left work perfectly the problem is the forward and backward, when I press either of them only one wheel turns and it's stuttering and will stop quickly, is it because 9V is too small for both motors?
if I press forward it will send 'F'
... do you receive an 'F'? – jsotola Oct 19 '19 at 16:07