Am I working my board too hard?

So I'm really new to programming and electronics, but I'm really familiar with rocketry. I want to develop an actively stabilized rocket similar to BPS.Space. I've come a long way with the pad, but I'm having issues getting it to work right. I have 2 5g servos and 3 LEDs. Those all play together nicely, but I have a transistor that I'm using to light the starter for the rocket's motor. I have the starter wired parallel to the board wired directly to the battery with the transistor as a switch. Whenever I try to light the starter, (switched with an LED for testing) it either won't come on, or the other electronics suffer, and it still won't turn on. I wrote a simple code to test the transistor, and it works just fine, but what am I missing?

A few questions come to mind:

What's the stall current of a single servo?

What's the maximum current you should draw out of the Arduino's 5V pin? (Hint: nowhere near enough to reliably run even one servo over the long term.)

What's the state of an input pin when its associated switch is open?

as far as the servos go, all they're doing is holding the rocket steady on the pad in the code, they're sent to their closed position, then when it's time for launch, they open and hold their position, so from what I understand, they shouldn't be drawing too much voltage, right? as for your question of the input pin, I'm not sure I understand what you're asking

How much voltage the servos draw is not the issue. How much current, is. Each time they start moving, they'll draw their stall current, which is very likely more than 500mA and could be in excess of an amp. The regulator on the Arduino is not designed for that. Use an external power supply.

When your switches are open, what's connected to the input pins? What state are they in? What will digitalRead show?

What current does the igniter draw ?
Only a second to light the rocket, but long enough to reset or corrupt the servo control.

As noted the servos are your immediate problem, but when you put an almost dead shott across the supply, bad things will happen.

Overall voltage & current planning up is really important when you add the igniters.

I rewired the servos to run in parallel with the board, but still nothing. the digitalRead is showing 14. I have no idea what that means

when I look online, it shows that the starters need anywhere from .5 to 2 amps to fire I tried wiring the starter in parallel to avoid any crazy spikes for the board, although I think I may be flawed with my thinking

You might not be understanding Ohm's Law well enough.

If your power supply, which may be a battery, can't source enough current for whatever (like a servo) then the voltage will drop.

You want to have a power supply that can source more current than you need so that voltage doesn't drop and you do not want to run more than 25 mA through an IO pin. So power the servos with supply outside of the board and switch that power with a transistor controlled by the board using signal level current.

Try to keep the volts stable, the current used is what burns or turns.

To light a fuse or engine igniter, you may want to charge a big capacitor over time then have that discharge quickly through the igniter. A capacitor can hold a lot of current compared to what a battery can supply. Multiple capacitors can multiply that!

  • Power the servos from the battery.

  • Vin needs to be 7 to 9v.

  • LEDs need a series dropping resistor.

  • The Switch pins need a 10k resistor to GND.

  • Add a safety switch to the Estes starter.

  • Suggest you use a relay, maybe a MOSFET.




  • In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

  • Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.

I'm not too sure what I did, but the LED is lighting up correctly and everything seems to be working. Powering the servos externally seemed to really help, so thanks for the tip. When I change over to a starter, the computer stalls again, so I may have to look at capacitors, or try a few different layouts with resistors

Way back when, I used a separate 9V pyro battery to charge up a 2200uF cap. That went to one side of the igniter, with the other connected to a N-channel logic level MOSFET in a TO-252 package. The ones I used were rated for up to 14A but I still had them soldered to a generous amount of copper for heat sinking. It was a royal pain to solder, as I recall. That circuit would pass enough current to ignite anything we threw at it, and the processor never blinked once.

There was also a current limited backup to charge the cap from the processor's battery. It wouldn't do to have a reset before the mains came out...

#include <Servo.h>;

Servo leftArm;
Servo rightArm;

const int red1 = 2;
const int red2 = 4;
const int green1 = 7;
const int launchCon = 16;
int condition = 1;
const int launchArm = 14;
const int vehicleDetect = 15;

int ignitor = 10;
int armState = 1;
int launchState = 0;
int vehiclePresent = 1;
int servoAngle = 0;
float countDown = 0;

void callAbort() {
  vehiclePresent = digitalRead(vehicleDetect);
  if (vehiclePresent == LOW) {
    condition = 5;
  }
}

void setup() {

  pinMode(red1, OUTPUT);
  pinMode(red2, OUTPUT);
  pinMode(green1, OUTPUT);
  pinMode(launchCon, INPUT);
  pinMode(launchArm, INPUT);
  pinMode(vehicleDetect, INPUT);
  pinMode(ignitor, OUTPUT);
  leftArm.attach(5);
  rightArm.attach(3);
  leftArm.write(1);
  rightArm.write(89);
  Serial.begin(9600);
  analogWrite(ignitor, 0);
}

void loop() {
  switch (condition) {
    case 1:  //pad idle
      callAbort();
      digitalWrite(red1, HIGH);
      digitalWrite(red2, HIGH);
      digitalWrite(green1, HIGH);
      Serial.println(condition);
      digitalRead(launchArm);
      Serial.println(launchArm);
      armState = digitalRead(launchArm);
      if (armState == HIGH) {
        condition = 2;
      }
      break;


    case 2:  //pad armed
      armState = digitalRead(launchArm);
      if (armState == LOW) {
        condition = 1;
      }
      callAbort();
      Serial.println(launchArm);
      digitalWrite(green1, LOW);
      digitalWrite(red1, LOW);
      digitalWrite(red2, HIGH);
      delay(500);
      digitalWrite(red1, HIGH);
      digitalWrite(red2, LOW);
      delay(500);
      Serial.println(condition);
      launchState = digitalRead(launchCon);
      if (launchState == HIGH) {
        condition = 3;
      }
      break;


    case 3:  //launch countdown
      armState = digitalRead(launchArm);
      if (armState == LOW) {
        condition = 6;
      }
      callAbort();
      Serial.println(condition);
      digitalWrite(red1, HIGH);
      digitalWrite(red2, HIGH);
      delay(250);
      digitalWrite(red1, LOW);
      digitalWrite(red2, LOW);
      delay(250);
      launchState = digitalRead(launchCon);
      if (launchState == LOW) {
        condition = 2;
        countDown = 0;
        servoAngle = 0;
      }
      countDown = countDown + 0.50;
      if (countDown >= 10) {
        leftArm.write(89);
        rightArm.write(1);
        delay(1000);
        analogWrite(ignitor, 255);
        delay(8000);
        vehiclePresent = digitalRead(vehicleDetect);
        if (vehiclePresent = LOW) {
          condition = 4;
        } else if (vehiclePresent = HIGH) {
          condition = 5;
        }
      }
      break;


    case 4:  //pad clear
      Serial.println(condition);
      digitalWrite(red1, LOW);
      digitalWrite(red2, LOW);
      digitalWrite(green1, HIGH);
      break;


    case 5:  //launch abort
      Serial.println(condition);
      digitalWrite(red1, HIGH);
      digitalWrite(red2, HIGH);
      digitalWrite(green1, LOW);
      analogWrite(ignitor, 0);
      break;

    case 6:  //pad disarm
      callAbort();
      Serial.println(condition);
      digitalWrite(red1, HIGH);
      digitalWrite(red2, HIGH);
      digitalWrite(green1, LOW);
      delay(500);
      digitalWrite(green1, HIGH);
      delay(500);
      launchState = digitalRead(launchCon);
      armState = digitalRead(launchArm);
      if (launchState == LOW && armState == LOW) {
        condition = 1;
      }
  }
}

I know the code is dirty, and it's not even done yet, but this is what I have so far based on the maybe 15 hours of C++ experience I have

  • Add break; to case 6.

  • if (vehiclePresent = LOW) and else if (vehiclePresent = HIGH) = is not the same as ==

thanks. I've corrected it. both of those issues are things I know, but I still forget... :man_facepalming:

The pins the Switches are connected to need 10k resistors to GND.

y'all are meaning 10,000 ohms, right?

  • Yes 10k is 10,000 ohms

  • Why are you using analogWrite(ignitor, 0); instead of digitalWrite(ignitor, 0); ? :thinking:

  • Add a series 220 ohm resistor to each LED.

I have it on a pwm pin, and I was playing with different values to see what would work. when I googled how to use a transistor with arduino, it kept telling me to have it on an analog pin. I used analogWrite to set different values and just copied and pasted the code and set it to 0. Is there a reason to use digitalWrite?

  • The Estes igniter would need full current (you have a 10R to limit current) so digitalWrite would work.

I'm trying to limit the current to under 800 mA since that's what the transistor can handle. I'm using a 2n2222 transistor