Society of Robots - Robot Forum

Software => Software => Topic started by: keithg on April 19, 2009, 05:15:54 AM

Title: Arduino loop exit - Brandon Sweeney's sketch
Post by: keithg on April 19, 2009, 05:15:54 AM
My elementary gifted students are designing an Arduino/EZ ultrasound robot that must stop after eight seconds.  Brandon Sweeney' s sketch is working well but the timing code is beyond us.  Is there a simple method?  His code is here:  http://pastie.org/451287 (http://pastie.org/451287)
Title: Re: Arduino loop exit - Brandon Sweeney's sketch
Post by: SmAsH on April 19, 2009, 05:24:39 AM
what do you mean by the timing code? is it a specific part of the code?
Title: Re: Arduino loop exit - Brandon Sweeney's sketch
Post by: offy on April 19, 2009, 10:02:00 AM
to delay a part of code for 8 seconds do this
delay(8000);

If you could be more specific it will be nice.
Title: Re: Arduino loop exit - Brandon Sweeney's sketch
Post by: Razor Concepts on April 19, 2009, 10:18:54 AM
If you would like to stop after 8 seconds, you could put this at the end of the setup loop:

if(millis() >= 8000)
{
while(1)
{
}
}
Title: Re: Arduino loop exit - Brandon Sweeney's sketch
Post by: keithg on April 19, 2009, 11:01:50 AM
I have pasted the code here: http://pastie.org/451511 (http://pastie.org/451511)  Having so little experience, I borrowed from several sources.  The motors need to stop and await manual restart by student players.  Thanks for the help. We need it!