Rocket Launch Controller

I'm currently building a launch controller for air rockets/model rockets. As of now, I have almost all of the hardware connected with the exception of powering everything. I also have some code done, but am having issues with code resets.

First question, how would I go about powering this? I have an Arduino with a relay shield on it, requiring 9v. When I hooked the Arduino up to the bench supply, it seemed to pull around 0.3A maximum. Should I just tie multiple 9v batteries in parallel, or use a larger 12v battery and regulate it down?

Next, I am having trouble with my code and software restarts. I have the code working, but I want it to be so once someone presses the button to launch, they have to release the arm button and the launch button in order to launch again.

This is my current code with something I found to restart the code, but I am not sure how to require the buttons to be released.

int const armButton = 52;
int const fireButton = 53;
int const relayPin1 = 2;
int const relayPin2 = 3;
int const relayPin3 = 4;
int const relayPin4 = 5;

boolean armPrinted = false;
boolean firePrinted = false;

void setup() {
  //Begin serial for debugging
  Serial.begin(9600);
 //Set buttons as inputs and log to serial
  pinMode(armButton, INPUT);
  Serial.println("Arm Button, INPUT");
  pinMode(fireButton, INPUT);
  Serial.println("Fire Button, INPUT");
  //Enable internal pull-ups
  digitalWrite(armButton, HIGH);
  digitalWrite(fireButton, HIGH);
  Serial.println("Pullups ENABLED");
  //Ser relay pins as outputs
  pinMode(relayPin1, OUTPUT);
  pinMode(relayPin2, OUTPUT);
  pinMode(relayPin3, OUTPUT);
  pinMode(relayPin4, OUTPUT);
  Serial.println("Relays set");

}

void loop() {
 while(digitalRead(armButton) == LOW) {  
  alertWarning();
  armPrint(); //while the arm button is pressed, log to serial armed, and stay ready.
  if(digitalRead(fireButton) == LOW) {
    launch(); //Run routine to launch, (Pull 1st relay high.
  }
  else {
  armedWaiting(); //If armed, but button not pressed, log to serial
}
 }
  
}

void armPrint() {
   if(!armPrinted){ //Check to see if arming message has already been printed
  Serial.println("ARMED"); //If not, print arming message
  armPrinted = true; /* Set arming message to be printed */ }
}

void armedWaiting() {
  Serial.println("Waiting");
  delay(500); 
}

void(* resetFunc) (void) = 0; //declare reset function @ address 0

void launch() {
  Serial.println("LAUNCHING");
  digitalWrite(relayPin1, HIGH);
  delay(500);
  digitalWrite(relayPin1, LOW);
  resetFunc();  //call reset
}

void alertWarning() {
  digitalWrite(relayPin4, HIGH);
   delay(500);
  digitalWrite(relayPin4, LOW);
   delay(500); 
}

You need to ensure that your system is safe on power up!

Mark

CFarrell99: First question, how would I go about powering this? I have an Arduino with a relay shield on it, requiring 9v. When I hooked the Arduino up to the bench supply, it seemed to pull around 0.3A maximum. Should I just tie multiple 9v batteries in parallel, or use a larger 12v battery and regulate it down?

Depends on how long you need the project to last.

Next, I am having trouble with my code and software restarts. I have the code working, but I want it to be so once someone presses the button to launch, they have to release the arm button and the launch button in order to launch again.

Sounds like you need a finite state machine.