
Project:
https://github.com/PepeTheFroggie/ESP32CAM_RCTANK
Code: Select all
//gas (speed) is 0 to +1000 forward, o to -1000 reverse
//dir (direction) is -500 to +500
rmot = gas+dir; // -1500 to +1500
lmot = gas-dir; // -1500 to +1500
if (rmot > 10)
{
motorA1 = constrain(+rmot / 4, 0, 255);
motorA2 = 0;
}
else if (rmot < -10)
{
motorA1 = 0;
motorA2 = constrain(-rmot / 4, 0, 255);
}
else
{
motorA1 = 0;
motorA2 = 0;
}
if (lmot > 10)
{
motorB1 = constrain(+lmot / 4, 0, 255);
motorB2 = 0;
}
else if (lmot < -10)
{
motorB1 = 0;
motorB2 = constrain(-lmot / 4, 0, 255);
}
else
{
motorB1 = 0;
motorB2 = 0;
}
writeMotors();
22$ with free shipping at aliexpress:
Users browsing this forum: No registered users and 106 guests