0

coding an end!
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

coding an end!

by big93 on Thu Dec 06, 2007 11:13 pm

hi, i want my code to stop at the end like i want all pins to be low, and then end the script, i dont want to keep looping it. only when i press the reset button, do i want it to re-start. is that possible? i'm used to typing "end" at the end and it stops, but it doesent seem to be accepting my scripting lol, thanks
-big93
big93
 
Posts: 56
Joined: Wed Nov 21, 2007 10:31 pm

by CCarlson on Fri Dec 07, 2007 10:24 am

At the point where you want processing to come to a halt, you could do this:

Code: Select all | TOGGLE FULL SIZE
while(1) {}


This should loop until power is cut.
CCarlson
 
Posts: 35
Joined: Mon Sep 24, 2007 11:55 am
Location: Hewitt, TX

by adafruit on Fri Dec 07, 2007 10:24 am

you can use the command
Code: Select all | TOGGLE FULL SIZE
while (1) {}

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by CCarlson on Fri Dec 07, 2007 10:55 am

You just made my day.
CCarlson
 
Posts: 35
Joined: Mon Sep 24, 2007 11:55 am
Location: Hewitt, TX

by big93 on Fri Dec 07, 2007 6:10 pm

thank you, and btw, this just completely stops the code, theres no going back on, or can you use while, to maybe stop the code until a button is pressed? cuz that would be cool!
Last edited by big93 on Sat Dec 08, 2007 12:50 am, edited 1 time in total.
big93
 
Posts: 56
Joined: Wed Nov 21, 2007 10:31 pm

by adafruit on Fri Dec 07, 2007 11:41 pm

sorry, i can't write your code for you
you could try posting to the arduino forum

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by big93 on Sat Dec 08, 2007 12:49 am

sorry, i think you mis understood, i dident mean to ask you to write me the code, i was asking if my above statement is simply possible, i forgot to add a question mark after, but it's edited, look at it again, it makes a lot more sense now, sry...
big93
 
Posts: 56
Joined: Wed Nov 21, 2007 10:31 pm

by joshthejest on Wed Dec 12, 2007 9:33 pm

Would an equivalent solution to be to not put anything in the loop function? You could turn all of the pins off at that point with code and it would just stop until you push the reset button.
joshthejest
 
Posts: 3
Joined: Thu Dec 06, 2007 5:56 pm

by mtbf0 on Thu Dec 13, 2007 12:12 am

use a button with a pullup on, for instance, digital pin 5.

try the following...

pinMode (5, INPUT);

while (1) {
// your existing code goes here

while digitalRead (5);
}

...should work, but may be a tad flaky because we're not debouncing the switch.
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

Please be positive and constructive with your questions and comments.