Hi Guys,
I am working on a Sumo bot, and if you have looked at them before, most rules require a 5 second pause before the battle begins.
I have all systems go with my bot, until I try to add in my delay for the start.
If I write it
{delay(5000);
{goFor();
randNumber = random(400, 600);
valfl = analogRead(irfl);
valfr = analogRead(irfr);
irrval = analogRead(irr);
irlval = analogRead(irl);
goFor();
if (valfl > 400)
left2();
if (valfr > 400)
right2();
if (irlval >750)
left();
if (irrval >750)
right();
}
}
The pause works properly, but my program doesn't work. The bot locks into goFor(); and never comes out.
If I write it
{delay(5000);
goFor();
randNumber = random(400, 600);
valfl = analogRead(irfl);
valfr = analogRead(irfr);
irrval = analogRead(irr);
irlval = analogRead(irl);
goFor();
if (valfl > 400)
left2();
if (valfr > 400)
right2();
if (irlval >750)
left();
if (irrval >750)
right();
}
This way loops the pause in every time.
If I write it
{del();
goFor();
randNumber = random(400, 600);
valfl = analogRead(irfl);
valfr = analogRead(irfr);
irrval = analogRead(irr);
irlval = analogRead(irl);
goFor();
if (valfl > 400)
left2();
if (valfr > 400)
right2();
if (irlval >750)
left();
if (irrval >750)
right();
}
void del()
{delay(5000)}
This way locks into the del void, and doesn't come out.
I don't know what else to do. Any ideas on what I should do? I have been banging my head against the wall on this. Is there a different type of delay that I can try? Or possibly some sort of interrupt? Thanks for any ideas.