I'm still trying to wrap my head around how the arduino is programmed compared to a Basic Stamp (pBasic).

In pBasic every program must have an END command to stop the program. I've noticed that in C++ (or at least arduino programming) the main program is basically a LOOP command that will repeat endlessly until power is removed from the arduino or the reset button is pressed.

My question is, can the arduino be programmed to end or will I have to encompass the entire program within a WHILE loop? If not, what would be a better way to program it to do so?

I have a flowchart made for a program where a decision is made. Each decision leads to a sequence of events that differ from each other but ultimately end. When I say it ends, I mean that the program cannot be run again until the arduino is powered down and back up again.

well in true C fashion you really should just turn it into a user defined function that you can call anywhere in your sketch you want, as so add the following code either before the setup() function of after the loop() function.

The majority of arduino projects you'll see on the forum run continuously, sensing something and acting on it. Some of course do have a definite end - beer brewing would be an example. Purely out of curiosity, what are you making?

The majority of arduino projects you'll see on the forum run continuously, sensing something and acting on it. Some of course do have a definite end - beer brewing would be an example. Purely out of curiosity, what are you making?

My wife's car has Push-To-Start ignition and as of right now there are no Immobilizer bypass or remote start solutions for it, so I'm creating one.

I have a remote start already, and an extra key-fob. I want to use the arduino to sense the remote start having been activated. Once 'activated' it will power on a burried key-fob so that the key information is radiated via RF into the car allowing engine startup. Next it will power up the brake circuit to simulate pressing in the brake pedal. The Arduino will then pulse the PTS button to fire up the engine, shutting off the key-fob afterwards preventing someone from getting into the vehicle and driving off with it. (the next part is the reason for wanting to end the program)

At this point the arduino will monitor the remote start's Status wire (shows ground when running, and floats high when off). If the Status wire drops ground it will pulse the PTS button twice to shut off the engine, and then pulse the driver's door pin wire to turn off the dome lights preventing battery drain. This is essentially to shut off the vehicle should the remote start time-out.

If the Arduino instead sees the brake pedal being pressed while the remote start is still running, it will not pulse the PTS button but will power off the remote start via the Brake Pedal Input sensing wire on the remote start. This will essentially allow key takeover.

The void stopSketch(void) is telling the compiler when it first compiles this function that it returns no value back to the calling program and requires no argument to be passed to it when it is called by the program.

During use in your sketch you just write stopSketch() and be done with it.

In a real mcu environment, you actually have the ability to led the code end and typically you restart from the beginning (making it effective a loop with setup()). In the arduino environment, you don't have that option right away, but you can manually edit the generated cpp file and perform make on your own.

In a real mcu environment, you actually have the ability to led the code end and typically you restart from the beginning (making it effective a loop with setup()). In the arduino environment, you don't have that option right away, but you can manually edit the generated cpp file and perform make on your own.

Well you certainly can within a sketch enable the watch dog timer (WDT) to time out and interrupt in just 25 millisec if you wish, which will effect a reset to the chip just as if you hit the reset switch or cycled the power off and on.

The void stopSketch(void) is telling the compiler when it first compiles this function that it returns no value back to the calling program and requires no argument to be passed to it when it is called by the program.

During use in your sketch you just write stopSketch() and be done with it.

Lefty

When I give my function declaration or definition is there any difference whether or not I put void in the parameter list or if I just use empty parenthesis? I know both will compile. But is there any larger reason to put the second void in there in the definition or declaration?

Ad hoc, ad loc, and quid pro quo. So little time - so much to know! ~Jeremy Hillary Boob Ph.D