Pages: [1]   Go Down
Author Topic: If to end?  (Read 647 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 239
Posts: 24371
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
if (x)
  while(1);
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8453
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

AWOL answered your question then you changed the brief.

Code:
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
« Last Edit: March 06, 2012, 06:11:44 pm by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Netherlands
Offline Offline
God Member
*****
Karma: 5
Posts: 614
A naughty mind is a joy forever.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8453
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Utah
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
            }
   
       }
           
Logged

Pages: [1]   Go Up
Jump to: