I'm trying to make a simple script that turns on a motor on a nerf blaster for a certain amount of time with a switch (fire) and choose the amount of time with another switch (button).
But it keeps crashing, which means the motor stays on or off until you reset the arduino and I can't seem to figure out why.
The arduino is powered by a 3s lipo, charged under 12V and powers an IRLB3034PBF mosfet.
How is everything wired up? A schematic (even hand drawn) would be useful. Do you have pull-up resistors on your inputs? Do you have any sort of diode across your motor to prevent spikes? It sounds a lot like you are seeing power spikes or dips which is resetting your board.
Switching large motor currents causes EMI, which, if not properly suppressed, will cause problems with sensitive digital circuits. Post a wiring diagram.