LAFVIN 4 motor robot car - 2 wheels

Hi,

I've read many posts on this, but they all assume a level of understanding I don't have. I am using code supplied with the car build kit from Lafvin (I've also read here their code can be poor) Its a lafvin 4 motor robot car kit, with L298N motor birdge. I have it wired as per diagram. Code here also. The issue is wheels on one side of car only. I can;t even try swapping left and right input signals as I can;t figure out which is which. EDIT sorry to add I have added code and wired for infra red control only. Added the IR library etc. But only one side wheels turn, they change forward and back on remote instruction. No change for left or right.

Can anyone help at all please?

Use code tags to format code for the forum

<#include <IRremote.h>
int RECV_PIN = 12;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define IR_Go 0x00ff629d
#define IR_Back 0x00ffa857
#define IR_Left 0x00ff22dd
#define IR_Right 0x00ffc23d
#define IR_Stop 0x00ff02fd
#define IR_ESC 0x00ff52ad
#define Lpwm_pin 5 //adjusting speed
#define Rpwm_pin 6 //adjusting speed //
int pinLB=2; // defining pin2 left rear
int pinLF=4; // defining pin4 left front
int pinRB=7; // defining pin7 right rear
int pinRF=8; // defining pin8 right front
unsigned char Lpwm_val =150;
unsigned char Rpwm_val = 150;
int Car_state=0;
void M_Control_IO_config(void)
{
pinMode(pinLB,OUTPUT); // pin2
pinMode(pinLF,OUTPUT); // pin4
pinMode(pinRB,OUTPUT); // pin7
pinMode(pinRF,OUTPUT); // pin8
pinMode(Lpwm_pin,OUTPUT); // pin5 (PWM)
pinMode(Rpwm_pin,OUTPUT); // pin6 (PWM)
}
void Set_Speed(unsigned char Left,unsigned char Right)
{
analogWrite(Lpwm_pin,Left);
analogWrite(Rpwm_pin,Right);
}
void advance() // going forward
{
digitalWrite(pinRB,LOW); // making motor move towards right rear
digitalWrite(pinRF,HIGH);
digitalWrite(pinLB,LOW); // making motor move towards left rear
digitalWrite(pinLF,HIGH);
Car_state = 1;
}
void turnR() //turning right(dual wheel)
{
digitalWrite(pinRB,LOW); //making motor move towards right rear
digitalWrite(pinRF,HIGH);
digitalWrite(pinLB,HIGH);
digitalWrite(pinLF,LOW); //making motor move towards left front
Car_state = 4;
}
void turnL() //turning left(dual wheel)
{
digitalWrite(pinRB,HIGH);
digitalWrite(pinRF,LOW ); //making motor move towards right front
digitalWrite(pinLB,LOW); //making motor move towards left rear
digitalWrite(pinLF,HIGH);
Car_state = 3;
}
void stopp() //stop
{
digitalWrite(pinRB,HIGH);
digitalWrite(pinRF,HIGH);
digitalWrite(pinLB,HIGH);
digitalWrite(pinLF,HIGH);
Car_state = 5;
}
void back() //back up
{
digitalWrite(pinRB,HIGH); //making motor move towards right rear
digitalWrite(pinRF,LOW);
digitalWrite(pinLB,HIGH); //making motor move towards left rear
digitalWrite(pinLF,LOW);
Car_state = 2;
}

void IR_Control(void)
{
unsigned long Key;
if(irrecv.decode(&results)) //judging if serial port receives data
{
Key = results.value;
switch(Key)
{
case IR_Go:advance(); //UP
break;
case IR_Back: back(); //back
break;
case IR_Left:turnL(); //Left
break;
case IR_Right:turnR(); //Righ
break;
case IR_Stop:stopp(); //stop
break;
default:
break;
}
irrecv.resume(); // Receive the next value
}

}
void setup()
{
M_Control_IO_config();
Set_Speed(Lpwm_val,Rpwm_val);
irrecv.enableIRIn(); // Start the receiver
Serial.begin(9600); //initializing serial port, Bluetooth used as serial port, setting baud ratio at 9600
stopp();
}
void loop()
{

IR_Control();

}

The problem usually is in (1) power and (2) wiring... so verify both.

Try this step-by-step device-testing method of building your robot car, and wait for using the IR.

Hiya thanks for the reply, appreciated.

Power is ok, it’s a single power source to the motor controller and only one output appears to be operating/switched. Wiring checked over a few times to the wiring diagram. I’ve not continuity checked each strand which is probably a good idea.

The guide posted and forgive what seem obvious but following it for the 4WD version does the fault finding follow a similar path? I really wanted my son to work through the various elements that we built (line tracking, collision avoidance etc which we fitted just not wired) but he only wanted to build and drive….
I’m going to try do some more learning, which pins are outputs and how they link to the sketch etc and also the motor controller. There’s some jumpers had to be removed to fit the wiring so I’ll try figure out what they do…

The Lafvin thread shows many "minimal code required" sketches to allow testing one device at a time. It should work for any project with the same devices.

I've never seen two motors wired in parallel. It seems to me you could have conflicts in the motors. Try disconnecting one from each side to see if they work individually.

Recently robot cars get wired this way to make a 4WD... not understanding the loss of torque on each motor and the battery drain.