Arduino stops working for current application and uploading new applications

I am working on a project to control a bipolar stepper motor. The speed of the motor is dependent on the setting provided by a PWM signal (0-5V) coming from a Unitronics M90 PLC. I am working with an Arduino Pro Mini 328 (5V) for this project.
The code to determine the setting from the PWM signal is

int pin = 2;
unsigned long duration;
void setup(){
  pinMode(pin, INPUT);
  Serial.begin(9600);
}

void loop(){
  duration = pulseIn(pin, HIGH);
  float setting = round((duration - 20.045) / 133.955);
  Serial.println(setting);
  delay(1000);
}

Originally I was powering the Arduino from my PC using the Arduino Mini USB adapter and I added the ground from the PLC to the Arduino to complete the circuit for the PLC, Everything went well and I was able to determine the linear equation for the setting values (as you can see in the code).

So I added a 5V regulator (LM340T5 7805) with the Vin connected to the PLC’s 14V power line, the Ground to the PLC’s ground and the Arduino’s ground, and the Vout to the RAW pin of the Arduino. I added another 5V regulator connected the same way but the Vout was connected the Vcc2 of an L293D motor controller. The 1,2EN, 3,4EN and Vcc1 were connected to the pin 13 of the Arduino which was set to high, programmatically. I first tried to make sure I could control the motor without the pwm signal and it worked.

Then I added the PWM signal on pin 2 of the Arduino and modified the code to read its signal. Upon testing, the Arduino suddenly stopped working and I could no longer upload code. A red light on the arduino was on but it wouldn’t do anything.

I put together a second Arduino Pro Mini 328 (5V) and took a step back leaving only the regulator for the arduino and removed all the motor related stuff. I connected the pwm signal again to pin 2. I modified my code to be

int pin = 2;
int blinker = 13;
unsigned long duration;
void setup(){
  pinMode(pin, INPUT);
  pinMode(blinker, OUTPUT);
}
void loop(){
  duration = pulseIn(pin, HIGH);
  float setting = round((duration - 20.045) / 133.955);
  blinkIt(setting); //blink the green light to show setting value
  delay(1000);
}
void blinkIt(float setting)
{
  int i;
  for(i = 0; i < setting; i++) //blink as many times as the setting
  {
    digitalWrite(blinker, HIGH);
    delay(250);
    digitalWrite(blinker, LOW);
    delay(250);
  }
  if(setting == 0) //on for one second
  {
    digitalWrite(blinker, HIGH);
    delay(1000);
    digitalWrite(blinker, LOW);
  }
}

I went to test it with the PWM signal off and as expected the green light stayed on for a second at a time. I turned on the PWM signal and suddenly things went wrong again. The light stopped doing anything. I disconnected everything and connected to the mini USB adapter again and I could not establish a connection with the Arduino. The red light on it comes on but it will not reset, upload new programs or do anything.

I am not sure what has happened nor how to diagnose the problem. Can someone please provide me with input as to how to identify the problem and/or fix it; I am at a loss. If there is any other information you need please ask and I will do my best to provide the information. I have lost 2 Arduinos to this now and I only have one left that I do not want to ruin.