Cool, I see where you are going (left, right and forward, LOL).
I’ll think about that for a bit, but it should be quite doable with an ESP or Arduino. I think the logic is sound, but I have to think about it for a bit.
What would happen if you just do a simple reverse mapping? Something along the lines of this:
BLYNK_WRITE(V0)
{
// Start or stop Robot button (simple push button, switch or push at your leisure)
int StartStop = param.asInt();
if(StartStop == 1) // Starting
{
analogWrite(E1, 30);
analogeWrite(E2, 30);
}
else // Stopping
{
analogWrite(M1, 0);
analogWrite(M2, 0);
}
}
BLYNK_WRITE(V1)
{
// param[x|y] goes from 0 - 255, center of joystick is 127, you probably could use a slider here too, maybe even easier?
int speedX = param[0].asInt();
int speedY = param[1].asInt();
// Turning left would map out from 0 - 127
// Turning right would map out fro 128 - 255
// Somewhere in the middle you have to go straight, 20 or so?
// so left would be from 0 - 107, right 138 - 255
// Map left/right values of joystick to left/right turning variables
int speedForM1 = map(speedX, 0, 255, 0, 107);
int speedForM2 = map(speedY, 0, 255, 138, 255);
// Fyi, constrain() makes sure values don't go above/below specified values
int correctedSpeedForM1 = constrain(speedX, 30, 255);
int correctedSpeedForM2 = constrain(speedY, 30, 255);
// Motor should be minimum of 30 + the amount to maximum of 255)
analogWrite(M1, correctedSpeedForM1);
analogWrite(M2, correctedSpeedForM2);
}
This is written up in about 10 minutes all form the top of my head, but you may be able to see the logic in this. This way the Robot will always have a minimum speed of 30, if you fancy this up you could set the minimum speed with a slider for better control. The map() X and Y are probably correct, but I’m not sure.