Need assistance setting Joystick control

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
 
#define RightMotorSpeed 4
#define RightMotorDir   0  
#define LeftMotorSpeed  5  
#define LeftMotorDir    2
 
char auth[] = "blynktoken";
char ssid[] = "ssid";
char pass[] = "password";

int minRange = 312;
int maxRange = 712;

int minSpeed = 450;
int maxSpeed = 1023;
int noSpeed = 0;
 
 
void moveControl(int x, int y)
{

  if(y >= maxRange && x >= minRange && x <= maxRange) //zataci R
  {
    digitalWrite(RightMotorDir,HIGH);  
    digitalWrite(LeftMotorDir,HIGH);
    analogWrite(RightMotorSpeed,maxSpeed); 
    analogWrite(LeftMotorSpeed,maxSpeed);
  }
  
  // move forward right
  else if(x >= maxRange && y >= maxRange)   //zataci R
  {
    digitalWrite(RightMotorDir,HIGH);
    digitalWrite(LeftMotorDir,HIGH);
   analogWrite(RightMotorSpeed,minSpeed); 
    analogWrite(LeftMotorSpeed,maxSpeed);
  }
 
  // move forward left
  else if(x <= minRange && y >= maxRange)
  {
    digitalWrite(RightMotorDir,HIGH);
    digitalWrite(LeftMotorDir,HIGH);
    analogWrite(RightMotorSpeed,maxSpeed); 
    analogWrite(LeftMotorSpeed,minSpeed);
  }
 
  // neutral zone
  else if(y < maxRange && y > minRange && x < maxRange && x > minRange)
  {
    analogWrite(RightMotorSpeed,noSpeed); 
    analogWrite(LeftMotorSpeed,noSpeed);
  }
 
 // move back
  else if(y <= minRange && x >= minRange && x <= maxRange)
  {
    digitalWrite(RightMotorDir,LOW);
    digitalWrite(LeftMotorDir,LOW);
   analogWrite(RightMotorSpeed,maxSpeed); 
    analogWrite(LeftMotorSpeed,maxSpeed);
  }
 
  // move back and right
 else if(y <= minRange && x <= minRange)
  {
   digitalWrite(RightMotorDir,LOW);
    digitalWrite(LeftMotorDir,LOW);
    analogWrite(RightMotorSpeed,minSpeed); 
    analogWrite(LeftMotorSpeed,maxSpeed);  
  }
 
  // move back and left
  else if(y <= minRange && x >= maxRange)
  {
    digitalWrite(RightMotorDir,LOW);
    digitalWrite(LeftMotorDir,LOW);
    analogWrite(RightMotorSpeed,maxSpeed); 
    analogWrite(LeftMotorSpeed,minSpeed);
  }
}
 
void setup()
{
  // initial settings for motors off and direction forward
  pinMode(RightMotorSpeed, OUTPUT);
  pinMode(LeftMotorSpeed, OUTPUT);
  pinMode(RightMotorDir, OUTPUT);
  pinMode(LeftMotorDir, OUTPUT);
  digitalWrite(RightMotorSpeed, LOW);
  digitalWrite(LeftMotorSpeed, LOW);
  digitalWrite(RightMotorDir, HIGH);
  digitalWrite(LeftMotorDir,HIGH);
 
  Blynk.begin(auth, ssid, pass);
 }
 
 
void loop()
{
  Blynk.run();
}
 
 
BLYNK_WRITE(V1)
{
  int x = param[0].asInt();
  int y = param[1].asInt();
  moveControl(x,y); 
}

Hi guys.

That is what I did. But is these values in blynk app are correct?

Caz tha car motors not working properly.

The code is correct. I just wanna know how to add values in joystik.
Thanks

First off… why are you using such a strange range of numbers? Why not something “normal” like 0-1023 (with 512 being mid point) or even better -512 to 512 with negative being one way, 0 being midpoint, and positive being the other way… then simply match your code to those settings?

Secondly, you have internal ranging set on your y axis (the squiggly circle in between the ranges)… is that intentional? I have never found it to be accurate.

Thanks Gunner,

But I am just beginner, I found this code in youtube but the guy didnt explaine how to put the values in the joystik blynk. So if u can help me and maje these valuse for me based on the code I will be thankful

Make

Well, this is something you need to learn, based on how your hardware/motors work.

In the Joystick settings, juse the defaults 0-1023 for both X & Y axis and see what happens… then, only if necessary, tweak the numbers in the code for your own preferences of MIN and MAX speed & direction settings.

The problem still not solve… can anyone send me the correct code with joystik values?

I am guessing you haven’t bothered searching this forum for recent examples of joystick controlled robot, car, rover, etc…

BTW, this really isn’t a Blynk related issue… you need to break that other person’s code down into understandable sections and figure out how it works before you can determine how to “fix” it for you particular application.

I know it is not a blunk related issue.

Can you pls send me any sketch for two dc motors with blynk values? Thanks

And yet you still beg for someone else’s code… that you will probably still be unable to use properly without understanding it… Hmmm :frowning:

Try this search parameter: joystick rover