BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

WiFi Car Needs separated inputs

Hi, I need help with a basic project. I have a car that I need to drive via WiFi. It has two motors. One for back and forward. One for left and right. It Does NOT drive like a tank.

The car is built already and it’s part done with Blynk. It has an issue though, it drives like a Tank. So when I press forward both motors spin and the car goes forward and steers left. So it Never drives in a straight line. The car has a steering wheel just like a regular car.

The sketch I have only allows me to use One joystick for both motors. This does not work for me, is undriveable like that. It goes forward and steers to one side and backwards and steers to the opposite side.

I need to separate the inputs into two joysticks. One joystick for steering and one for forward/backwards.

Can you help me with this ?

Here is the code I have

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define RightMotorSpeed 5
#define RightMotorDir 0
#define LeftMotorSpeed 4
#define LeftMotorDir 2

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "u-TK4OigDNek6bb1SiSn8o9O1ODjU9T-";
char ssid[] = "RC-CAR";
char pass[] = "k11092001";

void setup()
{
 Serial.begin(9600);
 Blynk.begin(auth, ssid, pass);

 pinMode(RightMotorSpeed, OUTPUT);
 pinMode(RightMotorDir, OUTPUT);
 pinMode(LeftMotorSpeed, OUTPUT);
 pinMode(LeftMotorDir, OUTPUT);
}

void loop()
{
 Blynk.run();
}

void halt()
{
 digitalWrite(RightMotorSpeed, LOW);
 digitalWrite(LeftMotorSpeed, LOW);
}

void forward()
{
 digitalWrite(RightMotorDir, HIGH);
 digitalWrite(LeftMotorDir, HIGH);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);
}

void reverse()
{
 digitalWrite(RightMotorDir, LOW);
 digitalWrite(LeftMotorDir, LOW);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);
}

void right()
{
 digitalWrite(RightMotorDir, LOW);
 digitalWrite(LeftMotorDir, HIGH);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);
}

void left()
{
 digitalWrite(RightMotorDir, HIGH);
 digitalWrite(LeftMotorDir, LOW);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);
}

BLYNK_WRITE(V0)
{
 if (param[0])
 forward();
 else
 halt();
}

BLYNK_WRITE(V1)
{
 if (param[0])
 reverse();
 else
 halt();
}

BLYNK_WRITE(V2)
{
 if (param[0])
 right();
 else
 halt();
}

BLYNK_WRITE(V3)
{
 if (param[0])
 left();
 else
 halt();
}```

@Hennesii please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Are you using a motor shield or driver such as a L293D? What’s your hookup? I would expect to see a motor speed between 0-1025 (lookup PWM pulse width modulation) not HIGH or LOW.

Yes Sir, there is a motor shield being used. The exact model would be CP2102.
Links to the hardware being used. https://www.amazon.com/gp/product/B075VMNLZR/ref=ppx_yo_dt_b_asin_title_o08_s01?ie=UTF8&psc=1

I have no idea about the code Sir, I paid someone to build it for me and that is what I got. I’m willing to pay for help that finally makes this car work like I want it to work. I never thought something that seems so basic would be so troublesome to finish. Is been about a year since I had the idea of trying this. It is just for fun, but at this point, I really want it to be done.

In reality, nobody is going to be able to give you a 100% working solution unless they have exactly the same hardware, including the car with motors.
The chances of that happening are very slim, so your best option is probably to learn more about C++ coding and experiment until you get the results you require.

Pete.

Post a picture of the car… a photo.

You cant use joustick on this car, only buttons, If you want use joustick you need left motor and right motor. And it will drive like a tank. Also your code is made for buttons not joustick.