Using Keypad to control stepper causing strange behavior

My final project goal is to use a 4x4 keypad to control a stepper motor and have each button correspond to a (as of yet undetermined) number of pulses. Additionally, I want a forward and reverse button.

Right now my code wont drive the motor, but the motor is responding with what seems to be a single pule. Its also responding to buttons I'm pressing but havent defined if statements for, so that is baffling.

Im new to programming so I appologize in advance for my ignorance.

In an effort to debug my approach I put together my stepper code using the standard button example and wired a single button, this worked without any issues.

My set up is a GeekDuino and RobotGeek button, with a NEMA 23 motor, a TB6600 driver and this keypad https://www.amazon.com/gp/product/B015M1CEIC/ref=od_aui_detailpages01?ie=UTF8&psc=1

Motor code that works no issue with simple button IMG 4094 - YouTube

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 13
; // the number of the pushbutton pin
//const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int dirpin = 0;
int steppin = 1;

void setup() {
// initialize the LED pin as an output:
// pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);

pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
int i;

digitalWrite(dirpin, LOW); // Set the direction.
delay(1000);

for (i = 0; i<4000; i++) // Iterate for 4000 microsteps.
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
delayMicroseconds(450); // This delay time is close to top speed for this
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(450); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.

digitalWrite(dirpin, HIGH); // Change direction.
delay(1000);

for (i = 0; i<400; i++) // Iterate for 4000 microsteps
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
delayMicroseconds(450); // This delay time is close to top speed for this
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(450); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.
}
}
'
HERE IS THE CODE THAT I AM HAVING ISSUES WITH IMG 4093 - YouTube

#include <Key.h>
#include <Keypad.h>

int dirpin = 0;
int steppin = 1;

/* the tutorial code for 3x4 Matrix Keypad with Arduino is as
This code prints the key pressed on the keypad to the serial port*/

const byte Rows= 4; //number of rows on the keypad i.e. 4
const byte Cols= 4; //number of columns on the keypad i,e, 3

//we will definne the key map as on the key pad:

char keymap[Rows][Cols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

// a char array is defined as it can be seen on the above

//keypad connections to the arduino terminals is given as:

byte rPins[Rows]= {2,3,4,5}; //Rows 0 to 3
byte cPins[Cols]= {6,7,8,9}; //Columns 0 to 3

// command for library forkeypad
//initializes an instance of the Keypad class
Keypad kpd= Keypad(makeKeymap(keymap), rPins, cPins, Rows, Cols);

void setup()
{
Serial.begin(9600); // initializing serail monitor
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
}

//If key is pressed, this key is stored in 'keypressed' variable
//If key is not equal to 'NO_KEY', then this key is printed out
void loop()
{

char keypressed = kpd.getKey();
if (keypressed != NO_KEY)
{
Serial.println(keypressed);

if (keypressed =='1'){
int i;

digitalWrite(dirpin, LOW); // Set the direction.
for (i = 0; i<400; i++) // Iterate for 4000 microsteps.
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
delayMicroseconds(450); // This delay time is close to top speed for this
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(450); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.
Serial.println("hERE IS AM");
digitalWrite(dirpin, HIGH); // Change direction.
delay(1000);

for (i = 0; i<400; i++) // Iterate for 4000 microsteps
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
delayMicroseconds(450); // This delay time is close to top speed for this
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(450); // This delay time is close to top speed for this
} // particular motor. Any faster the motor stalls.
Serial.println("sECOND sAM");
}
}
}

It seems that it had something to do with the PWM
I loaded just a keypad program and it is still sending pulses to the stepper without any code associated with the stepper pins 0 and 1.

int dirpin = 0;
int steppin = 1;
void setup()
{
     Serial.begin(9600);  // initializing serail monitor

Pins 0 and 1 are the hardware serial pins. You can't use pin 0 and 1 for both Serial AND your stepper. You need to pick different pins for your stepper.

It seems you are right I got good results when moving to pin 10 and 11

int dirpin = 10;
int steppin = 11;

Which pin defaults as serial?
Thank you,

I found some other issues

I would like the '*' to run the motor forward and the '#' in reverse slowly
I cant figure out code to make it only run while held down this is with trying a lot of things like messing around with while and break dif for and if conditions. I know its simple but I cant get it(SEE END OF CODE)

 if (keypressed =='*'){ //This works but ideally it would be moving only while held down
        
        
         digitalWrite(dirpin, LOW);     // Set the direction.
        for (i = 0; i<25; i++)       // Iterate for 25 microsteps to move in rev 1/8 of turn
          {
            digitalWrite(steppin, LOW);  // This LOW to HIGH change is what creates the
            delayMicroseconds(1500);      // This delay time is close to top speed for this
            digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
            delayMicroseconds(1500);      // This delay time is close to top speed for this
          }                              // particular motor. Any faster the motor stalls.
            Serial.println("FWD FEED");
            
      }

             
     if (keypressed =='#'){
 
         digitalWrite(dirpin, HIGH);     // Set the direction.
       for (i = 0; i<25 ; i++)       // Iterate for 25 microsteps to move in rev 1/8 of turn
       {
            
            digitalWrite(steppin, LOW);  // This LOW to HIGH change is what creates the
            delayMicroseconds(1500);      // This delay time is close to top speed for this
            digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
            delayMicroseconds(1500);      // This delay time is close to top speed for this
          }                              // particular motor. Any faster the motor stalls.
            Serial.println("REV FEED");      
      }