Hi guys I have been programming a rover 5 tank the past few weeks and have successfully implemented a rc, and autonomous mode that uses a ir compound eye to follow objects. I have been trying to add a "bored" function to my code but am not getting right. Attached is the code, any help will be greatly appreciated.
So my sensor is on a pan/tilt bracket so when robot turns its head to a follow object it should reset the boredom counter, if not it should count up to 30 and then run the bored function (print bored into serial).
but after the 30 seconds, even if the robot sees something its keeps printing bored.
switch(controlMode)
{
case 0:
irEye();
irFollow();
if(boredom>2)Bored();
break;
case 1:
rcMode();
break;
}
}
if (panadjust < 6 || tiltadjust < 6)// reset bordom counter if object moves enough
{
unsigned long loopTime = millis() - startTime;
if (loopTime > 30000)boredom=3;
}
else
{
startTime = millis();
}