Go Down

Topic: If to end? (Read 954 times) previous topic - next topic

gilberto

Hi!

I want to use the if as a condition and then if the answer is true, the program will stom automatically and ingnore all the remaining parts of the program. How can I do that?

AWOL

Code: [Select]
if (x)
  while(1);
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

gilberto

Sorry but what does that code do?

What if I want to start the program all over again whenever the answer to my If statement is true.
What I need is like a master reset.

Graynomad

#3
Mar 07, 2012, 12:09 am Last Edit: Mar 07, 2012, 12:11 am by Graynomad Reason: 1
AWOL answered your question then you changed the brief.

Code: [Select]
loop () {
   if (!x)
     while(1);  // x is false so stop program

   // do other stuff
}


This will constantly execute normal code until x == false.

Or do you want to stop then restart when something happens?

Explain exactly what needs to happen.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Simpson_Jr

Must say I haven't tried it, just did an search "software reset arduino", maybe solutions in this thread can help you further.

Graynomad

There are ways to "reset" the Arduino using software, a simple "jmp 0" for example, but I don't think I've ever heard a valid argument for doing so.

OP, tell us what you are trying to achieve.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

thebfs

i dont think  its a reset its a freeze
your progam runs


void setup;
int run = HIGH;
void loop;
       
       if ( run = HIGH){
           //run  your program here
     
              //when you want to exit
            if (your condition = true){
                 run = LOW; //your program wont run again till you reset.
            }
   
       }
         

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy