Author Topic: Arduino loop exit - Brandon Sweeney's sketch  (Read 10171 times)

0 Members and 1 Guest are viewing this topic.

Offline keithgTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Arduino loop exit - Brandon Sweeney's sketch
« 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

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Arduino loop exit - Brandon Sweeney's sketch
« Reply #1 on: April 19, 2009, 05:24:39 AM »
what do you mean by the timing code? is it a specific part of the code?
Howdy

Offline offy

  • Supreme Robot
  • *****
  • Posts: 340
  • Helpful? 1
Re: Arduino loop exit - Brandon Sweeney's sketch
« Reply #2 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.

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
    • RazorConcepts
Re: Arduino loop exit - Brandon Sweeney's sketch
« Reply #3 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)
{
}
}

Offline keithgTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Arduino loop exit - Brandon Sweeney's sketch
« Reply #4 on: April 19, 2009, 11:01:50 AM »
I have pasted the code here: 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!