Stepper Kill Switch

With all problems of combining two parts of a project where one is an input device (kill switch) and one is an output device (motor), you need to define an appropriate variable or variables. Test that the input section correctly sets this variable, test that the output code correctly interprets this variable (can be tested entirely separately, see).

Then you combine the code and they communicate via this variable. Here you just need a boolean, perhaps called "kill_switch", or alternatively use the opposite logic and call it "motor_enabled".

Slightly more sophisticated (and more useful if each section is destined to be in a library eventually), you define a function called something like "emergency_kill_switch()" that operates the variable - then the variable is encapsulated inside the motor handling code and you just have to add a call to this function in the switch-detecting code.