Arduino programming ... HELP!!!!?

I am currently working on a project that involves using arduino to autonomously control a boat. But before we start controlling the boat with arduino, we need to first arm the boat.. i.e make sure the thrusters and rudders are working fine and we only want to do this once. But because the code to arm the boat is in the void loop() ... it would keep on repeating and thats where i need your help.. Is there a way to check if the boat has been armed once, it should stop and move to the next part of the program.. Below is the code i have already worked, obviously its not working.. Really need your help you guys .. Thanks ..

//First Stage Autonomous Control of Rover Boat

#include <Servo.h>

Servo Rudders; // Note rudders are controlled together not individually
Servo fThrust1; // Starboard ducted fan
Servo fThrust2; // Port ducted fan
Servo rThrust; // Reverse engine

// Min and Max servo position in microseconds
int minPulse = 850; // Approx. abs(min) settings: 800 Pulse 17 position
int maxPulse = 2250; // Approx. abs(max) settings: 2280 Pulse 180 position

boolean armed = false;

void setup()
{
// Attach each Servo object to a digital pin
Rudders.attach(9, minPulse, maxPulse);
fThrust1.attach(10, minPulse, maxPulse);
fThrust2.attach(10, minPulse, maxPulse);
rThrust.attach(11, minPulse, maxPulse);

}

void Arm()
{

fThrust1.write(0);
fThrust2.write(0);
rThrust.write(0);
delay(2000);

fThrust1.write(180);
fThrust2.write(180);
rThrust.write(180);
delay(2000);

fThrust1.write(0);
fThrust2.write(0);
rThrust.write(0);
delay(2000);

}

void loop()
{

if(!armed)
{
Arm();
}

}

That's what the setup() function is for

You mind explaining what you mean ... I'm kinda new to arduino

lionel007:
You mind explaining what you mean ... I'm kinda new to arduino

The setup() function only runs once.

The loop() function runs over and over again.

If you want something to only happen once, put it in the setup() function.

That's what the setup() function is for

Yes, move your ARM code section to the setup() function.
setup() runs once when the Arduino is reset.

Arrch beat me to it.

Either put the arming code in the setup() function where it will only run once or, if it must be in the loop() function, set a global variable, let's call it OKtoArm, to true at the start of the program, check it before running the arming code, only arm if it is true then, as part of the arming process set it to false to stop it running again.

Looking at your code it works the second way and looks OK apart from the fact that you do not set armed to true once you had armed the motor.

like UKHeliBob described:

 //First Stage Autonomous Control of Rover Boat

 #include <Servo.h>

 Servo Rudders; // Note rudders are controlled together not individually
 Servo fThrust1; // Starboard ducted fan
 Servo fThrust2; // Port ducted fan
 Servo rThrust; // Reverse engine

 // Min and Max servo position in microseconds
 int minPulse = 850; // Approx. abs(min) settings: 800 Pulse 17 position
 int maxPulse = 2250; // Approx. abs(max) settings: 2280 Pulse 180 position

 boolean armed = false;

 void setup() 
 { 
 // Attach each Servo object to a digital pin
 Rudders.attach(9, minPulse, maxPulse);
 fThrust1.attach(10, minPulse, maxPulse);
 fThrust2.attach(10, minPulse, maxPulse);
 rThrust.attach(11, minPulse, maxPulse);

 }

 void Arm()
 {

 fThrust1.write(0);
 fThrust2.write(0);
 rThrust.write(0);
 delay(2000);

 fThrust1.write(180);
 fThrust2.write(180);
 rThrust.write(180);
 delay(2000);

 fThrust1.write(0);
 fThrust2.write(0);
 rThrust.write(0);
 delay(2000);

 armed = true;

 }

 void loop()
 {

 if(!armed)
 {
 Arm();
 }

 }