Go Down

Topic: If to end? (Read 1 time) previous topic - next topic



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?


Code: [Select]
if (x)
"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.


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.


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 Gray aka the GRAYnomad www.robgray.com


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


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 Gray aka the GRAYnomad www.robgray.com


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!

via Egeo 16
Torino, 10131