Jump to content


Photo

How to run an arduino sketch only once?


  • Please log in to reply
5 replies to this topic

#1 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:20 PM

Hi everyone,

is it possible to run an Arduino sketch (using the c_environment) where the loop runs only once and exit?

Thanks



#2 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:20 PM

Yes. If you are using C_environment. You can dig into the main code, and find out where loop function is called.



#3 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:20 PM

Hey!

loop() and setup() are located here:

https://github.com/p...rduino/main.cpp

You can remove infinite loop for(;wink.gif and serial event handling too..

Greets,
Alex.



#4 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:21 PM

exit(0);
 


#5 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:21 PM

exit(0);
 

+1 Yeah you've right easier is better :-)



#6 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:21 PM

exit(0);
 

+1 Yeah you've right easier is better :-)
 


Arduino doesn't have an exit but C does.  wink.gif






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users