user52988: This is Arduino RC control car, the sketch tested good in a small motor, but burned two 60A drivers when put into 24V,500W motors, need help to find out whats wrong?
#include <VirtualWire.h>


//motor A connected between A01 and A02
//motor B connected between B01 and B02

int STBY = 2; //standby  // mod: was 10 --2 ??

int count;

//Motor A
int PWMA = 9; //Speed control   // need mod: was 3 change into 9
int AIN1 = 8; //Direction  // was 9
int AIN2 = 7; //Direction

//Motor B
int PWMB = 10; //Speed control   // need mod: was 5 change into 10
int BIN1 = 5; //Direction   // was 6
int BIN2 = 4; //Direction   ///was 16 put into p7 cause of Arduino uno no p16.

const boolean FORWARD = HIGH;
const boolean REVERSE = LOW;

float speed_Max = 252; //pwm usually goes from was:0-255 ////0-255 changed into 0-252

float speed_Min = 0;
float analogInput_Max = 1023;
float analogInput_Min = 0;
float analogInput_Middle_X = 515;//ideally it would be analogInput_Max / 2
float analogInput_Middle_Y = 495;//ideally it would be analogInput_Max / 2
float deadBand = 0;
float middleMax = (analogInput_Max / 2) + deadBand;
float middleMin = (analogInput_Max / 2) - deadBand;
boolean pastDirection = FORWARD;

void setup()
{
  // Configure Timer 2 for PWM @ 14 kHz.
  TCCR2A = 0;           // undo the configuration done by...
  TCCR2B = 0;           // ...the Arduino core library
  TCNT2  = 0;           // reset timer

  TCCR2A = _BV(COM2A1)  // non-inverted PWM on ch. A
           | _BV(COM2B1)  // same on ch; B
           | _BV(WGM20);  // mode 10: ph. correct PWM, TOP = ICR1

      TCCR2B = (TCCR2B & 0b11111000) | 0x01; //3.92116 [kHz] //** use this code got 3.9khz but joystick works not too good
    {

    Serial.begin(9600);  // Debugging only
    Serial.println("setup"); //Prints "Setup" to the serial monitor

    vw_set_rx_pin(6);       //Sets pin D12 as the RX Pin
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);      // Bits per sec
    vw_rx_start();       // Start the receiver PLL running

    pinMode(23, OUTPUT); //Relay one ////M1 added 2 was 2 -- 4
    pinMode(25, OUTPUT); //Relay two
    pinMode(27, OUTPUT); //Relay four
    pinMode(29, OUTPUT); //Relay five
    pinMode(31, OUTPUT); //Relay sex
    pinMode(33, OUTPUT); //Relay seven
    pinMode(35, OUTPUT); //Relay eight
    pinMode(37, OUTPUT); //Relay three
    pinMode(39, OUTPUT); //Relay three
    pinMode(41, OUTPUT); //Relay eight
    pinMode(43, OUTPUT); //Relay three
    pinMode(45, OUTPUT); //Relay three

    digitalWrite(23, HIGH); 
    digitalWrite(25, HIGH);
    digitalWrite(27, HIGH);
    digitalWrite(29, HIGH);
    digitalWrite(31, HIGH);
    digitalWrite(33, HIGH);
    digitalWrite(35, HIGH);
    digitalWrite(37, HIGH);
    digitalWrite(39, HIGH);
    digitalWrite(41, HIGH);
    digitalWrite(43, HIGH);
    digitalWrite(45, HIGH);
     }

  pinMode(STBY, OUTPUT); //// pin: the number of the pin whose mode you wish to set; mode: INPUT, OUTPUT, or INPUT_PULLUP.

  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);

  pinMode(PWMB, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
}

void loop() {

button(); //// disable 'button', no work. remove '//' enable, button works good
joystick(); //// disable 'joystick', no work. remove '//' enable, joystick works good, but no motor control yet

 }

void joystick() {

  uint8_t buf[VW_MAX_MESSAGE_LEN]; // This declares a variable array. instead of 7 variables buf1, buf2 etc...
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    int i;
    int column = 0;
    String message;
    int commands[30];
    // Message with a good checksum received, dump it.
    for (i = 0; i < buflen; i++)
    {
      //DEBUG:
      //Serial.print(char(buf[i]));

      if (char(buf[i]) == '|') {
        commands[column] = message.toInt();
        message = "";
        column++;
      } else {
        message += char(buf[i]);
      }
    }

    //one more time to capture the last value since the message does not end with |
    commands[column] = message.toInt();

    // DEBUG
    //    Serial.print("X: ");
    //    Serial.print(commands[0]);
    //    Serial.print(" Y: ");
    //    Serial.println(commands[1]);

     motorControl(commands[0], commands[1]);

  }

}

void move(int motor, int speed, boolean direction) {
  digitalWrite(STBY, HIGH); //disable standby

   if (motor == 1) {
    digitalWrite(AIN1, direction);
    digitalWrite(AIN2, !direction);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, !direction);
    digitalWrite(BIN2, direction);
    analogWrite(PWMB, speed);
  }
}

void motorControl(float x, float y) {
  boolean currentDirection = y >= analogInput_Middle_Y;

    //map(value, fromLow, fromHigh, toLow, toHigh);
  if (currentDirection == REVERSE) {
    y = map(y, analogInput_Middle_Y, analogInput_Min, speed_Min, speed_Max) ;
  } else {
    y = map(y, analogInput_Middle_Y, analogInput_Max, speed_Min, speed_Max);
  }

  int subtractFromLeft = map(x, analogInput_Middle_X, analogInput_Min, speed_Min, y);
  int subtractFromRight = map(x, analogInput_Middle_X, analogInput_Max, speed_Min, y);

  if (subtractFromRight < 0) {
    subtractFromRight = 0;
  }

  if (subtractFromLeft < 0) {
    subtractFromLeft = 0;
  }

  int Throttle_RIGHT = y - subtractFromRight;
  int Throttle_LEFT = y - subtractFromLeft;

  boolean currentDirection_LEFT = currentDirection;
  boolean currentDirection_RIGHT = currentDirection;


  if (Throttle_LEFT < 1 && Throttle_RIGHT > 1) {
    currentDirection_LEFT = !currentDirection;
    Throttle_LEFT = Throttle_RIGHT;
  }

  if (Throttle_RIGHT < 1 && Throttle_LEFT > 1) {
    currentDirection_RIGHT = !currentDirection;
    Throttle_RIGHT = Throttle_LEFT;
  }

  move(1, Throttle_LEFT, currentDirection_LEFT);
  move(2, Throttle_RIGHT, currentDirection_RIGHT);

  }

void button()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    int i;
    digitalWrite(13, true);  // Flash a light to show received good message
    // Message with a good checksum received, dump it.
    Serial.print("Got: ");

    for (i = 0; i < buflen; i++)
    {
      int c = (buf[i]);
      Serial.print(c);
      Serial.print(" ");
      if (c == 65 ) {
        digitalWrite(23, !digitalRead(23));  //// A--RELAY A1
      }

      if (c == 66 ) {
        digitalWrite(25, !digitalRead(25));  //// B--RELAY A2
      }

      if (c == 67 ) {
        digitalWrite(27, !digitalRead(27)); //// C--RELAY B1
      }

      if (c == 68 ) {
        digitalWrite(29, !digitalRead(29)); //// D--RELAY B2
      }
/*      
      if (c == 69 ) {
        digitalWrite(37, !digitalRead(37)); //// E--
      }

      if (c == 70 ) {
        digitalWrite(39, !digitalRead(39)); //// F--
      }
*/
      if (c == 71 ) {
        digitalWrite(31, !digitalRead(31)); //// G--RELAY C1
      }

      if (c == 72 ) {
        digitalWrite(33, !digitalRead(33));  //// H -- RELAY C2
      }

      if (c == 73 ) {
        digitalWrite(43, !digitalRead(43));  //// I --
      }

       if (c == 74 ) {
        digitalWrite(35, !digitalRead(35));  //// J --
      }

       if (c == 75 ) {
        digitalWrite(37, !digitalRead(37));  //// K --
      }

      if (c == 76 ) {
        digitalWrite(39, !digitalRead(39));  //// L --
      }
      if (c == 77 ) {
        digitalWrite(41, !digitalRead(41));  //// M --
      }
      if (c == 78 ) {
        digitalWrite(35, !digitalRead(35));  //// N --
      }

    }
    count++;
    // Serial.print(count);
    Serial.println("");
    digitalWrite(13, false);
  }
}

My new driver is came, I just scare to use it, heard that DC motor will draw upto 300A at the start, what should I do to reduce the start current? 

user34529: As you wrote in comment you use this H bridge:
https://www.ebay.com/itm/60A-DC-Motor-Driver-Module-High-Power-motor-Speed-Control-Dual-Channel-H-bridge/122479397950
The description how to use it is clear:

But the listing doesn't say what will happen when you set state of A1,A2=1.1 to that H-bridge.
When you set value of A1,A2=1.1 to a unprotected (cheap) H-Bridge you get a direct short to ground through 2 transistors burning them instantly

Your code actually does not protect against that:
   if (motor == 1) {
    digitalWrite(AIN1, direction);
    digitalWrite(AIN2, !direction);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, !direction);
    digitalWrite(BIN2, direction);
    analogWrite(PWMB, speed);
  }
}

If previous value of direction is 0 (A1,A2=0,1) and you want to set direction to 1 (A1,A2=1,0) when arduino runs the line digitalWrite(AIN1, direction); for few cycles you actually end up with A1,A2=1,1 and MOSFETs go bye bye.
Try setting AIN1, AIN2 (or BIN1, BIN2) to 0 before adjusting the direction
   if (motor == 1) {
    digitalWrite(AIN1, LOW);
    digitalWrite(AIN2, LOW);

    digitalWrite(AIN1, direction);
    digitalWrite(AIN2, !direction);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, LOW);
    digitalWrite(BIN2, LOW);

    digitalWrite(BIN1, !direction);
    digitalWrite(BIN2, direction);
    analogWrite(PWMB, speed);
  }
}

This way you are guaranteed that you always have at least one 0 there.
EDIT:
You wrote that the module contains IR2103s it should protect you from the problem I described above. (But my suggested fix is not dangerous so you can use it just in case)
There is another possibility. Maybe the rapidly changing of the direction induces high voltage spikes in the motor, and that burns the circuit. Do you see any power diodes there? Look at the image I pasted above it has 4 diodes that should safely discharge those spikes. Make sure your code does not change direction every few milliseconds.

52988: <p>This is Arduino RC control car, the sketch tested good in a small motor, but burned two 60A drivers when put into 24V,500W motors, need help to find out whats wrong?</p>

<pre><code>#include &lt;VirtualWire.h&gt;


//motor A connected between A01 and A02
//motor B connected between B01 and B02

int STBY = 2; //standby  // mod: was 10 --2 ??

int count;

//Motor A
int PWMA = 9; //Speed control   // need mod: was 3 change into 9
int AIN1 = 8; //Direction  // was 9
int AIN2 = 7; //Direction

//Motor B
int PWMB = 10; //Speed control   // need mod: was 5 change into 10
int BIN1 = 5; //Direction   // was 6
int BIN2 = 4; //Direction   ///was 16 put into p7 cause of Arduino uno no p16.

const boolean FORWARD = HIGH;
const boolean REVERSE = LOW;

float speed_Max = 252; //pwm usually goes from was:0-255 ////0-255 changed into 0-252

float speed_Min = 0;
float analogInput_Max = 1023;
float analogInput_Min = 0;
float analogInput_Middle_X = 515;//ideally it would be analogInput_Max / 2
float analogInput_Middle_Y = 495;//ideally it would be analogInput_Max / 2
float deadBand = 0;
float middleMax = (analogInput_Max / 2) + deadBand;
float middleMin = (analogInput_Max / 2) - deadBand;
boolean pastDirection = FORWARD;

void setup()
{
  // Configure Timer 2 for PWM @ 14 kHz.
  TCCR2A = 0;           // undo the configuration done by...
  TCCR2B = 0;           // ...the Arduino core library
  TCNT2  = 0;           // reset timer

  TCCR2A = _BV(COM2A1)  // non-inverted PWM on ch. A
           | _BV(COM2B1)  // same on ch; B
           | _BV(WGM20);  // mode 10: ph. correct PWM, TOP = ICR1

      TCCR2B = (TCCR2B &amp; 0b11111000) | 0x01; //3.92116 [kHz] //** use this code got 3.9khz but joystick works not too good
    {

    Serial.begin(9600);  // Debugging only
    Serial.println("setup"); //Prints "Setup" to the serial monitor

    vw_set_rx_pin(6);       //Sets pin D12 as the RX Pin
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);      // Bits per sec
    vw_rx_start();       // Start the receiver PLL running

    pinMode(23, OUTPUT); //Relay one ////M1 added 2 was 2 -- 4
    pinMode(25, OUTPUT); //Relay two
    pinMode(27, OUTPUT); //Relay four
    pinMode(29, OUTPUT); //Relay five
    pinMode(31, OUTPUT); //Relay sex
    pinMode(33, OUTPUT); //Relay seven
    pinMode(35, OUTPUT); //Relay eight
    pinMode(37, OUTPUT); //Relay three
    pinMode(39, OUTPUT); //Relay three
    pinMode(41, OUTPUT); //Relay eight
    pinMode(43, OUTPUT); //Relay three
    pinMode(45, OUTPUT); //Relay three

    digitalWrite(23, HIGH); 
    digitalWrite(25, HIGH);
    digitalWrite(27, HIGH);
    digitalWrite(29, HIGH);
    digitalWrite(31, HIGH);
    digitalWrite(33, HIGH);
    digitalWrite(35, HIGH);
    digitalWrite(37, HIGH);
    digitalWrite(39, HIGH);
    digitalWrite(41, HIGH);
    digitalWrite(43, HIGH);
    digitalWrite(45, HIGH);
     }

  pinMode(STBY, OUTPUT); //// pin: the number of the pin whose mode you wish to set; mode: INPUT, OUTPUT, or INPUT_PULLUP.

  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);

  pinMode(PWMB, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
}

void loop() {

button(); //// disable 'button', no work. remove '//' enable, button works good
joystick(); //// disable 'joystick', no work. remove '//' enable, joystick works good, but no motor control yet

 }

void joystick() {

  uint8_t buf[VW_MAX_MESSAGE_LEN]; // This declares a variable array. instead of 7 variables buf1, buf2 etc...
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &amp;buflen)) // Non-blocking
  {
    int i;
    int column = 0;
    String message;
    int commands[30];
    // Message with a good checksum received, dump it.
    for (i = 0; i &lt; buflen; i++)
    {
      //DEBUG:
      //Serial.print(char(buf[i]));

      if (char(buf[i]) == '|') {
        commands[column] = message.toInt();
        message = "";
        column++;
      } else {
        message += char(buf[i]);
      }
    }

    //one more time to capture the last value since the message does not end with |
    commands[column] = message.toInt();

    // DEBUG
    //    Serial.print("X: ");
    //    Serial.print(commands[0]);
    //    Serial.print(" Y: ");
    //    Serial.println(commands[1]);

     motorControl(commands[0], commands[1]);

  }

}

void move(int motor, int speed, boolean direction) {
  digitalWrite(STBY, HIGH); //disable standby

   if (motor == 1) {
    digitalWrite(AIN1, direction);
    digitalWrite(AIN2, !direction);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, !direction);
    digitalWrite(BIN2, direction);
    analogWrite(PWMB, speed);
  }
}

void motorControl(float x, float y) {
  boolean currentDirection = y &gt;= analogInput_Middle_Y;

    //map(value, fromLow, fromHigh, toLow, toHigh);
  if (currentDirection == REVERSE) {
    y = map(y, analogInput_Middle_Y, analogInput_Min, speed_Min, speed_Max) ;
  } else {
    y = map(y, analogInput_Middle_Y, analogInput_Max, speed_Min, speed_Max);
  }

  int subtractFromLeft = map(x, analogInput_Middle_X, analogInput_Min, speed_Min, y);
  int subtractFromRight = map(x, analogInput_Middle_X, analogInput_Max, speed_Min, y);

  if (subtractFromRight &lt; 0) {
    subtractFromRight = 0;
  }

  if (subtractFromLeft &lt; 0) {
    subtractFromLeft = 0;
  }

  int Throttle_RIGHT = y - subtractFromRight;
  int Throttle_LEFT = y - subtractFromLeft;

  boolean currentDirection_LEFT = currentDirection;
  boolean currentDirection_RIGHT = currentDirection;


  if (Throttle_LEFT &lt; 1 &amp;&amp; Throttle_RIGHT &gt; 1) {
    currentDirection_LEFT = !currentDirection;
    Throttle_LEFT = Throttle_RIGHT;
  }

  if (Throttle_RIGHT &lt; 1 &amp;&amp; Throttle_LEFT &gt; 1) {
    currentDirection_RIGHT = !currentDirection;
    Throttle_RIGHT = Throttle_LEFT;
  }

  move(1, Throttle_LEFT, currentDirection_LEFT);
  move(2, Throttle_RIGHT, currentDirection_RIGHT);

  }

void button()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &amp;buflen)) // Non-blocking
  {
    int i;
    digitalWrite(13, true);  // Flash a light to show received good message
    // Message with a good checksum received, dump it.
    Serial.print("Got: ");

    for (i = 0; i &lt; buflen; i++)
    {
      int c = (buf[i]);
      Serial.print(c);
      Serial.print(" ");
      if (c == 65 ) {
        digitalWrite(23, !digitalRead(23));  //// A--RELAY A1
      }

      if (c == 66 ) {
        digitalWrite(25, !digitalRead(25));  //// B--RELAY A2
      }

      if (c == 67 ) {
        digitalWrite(27, !digitalRead(27)); //// C--RELAY B1
      }

      if (c == 68 ) {
        digitalWrite(29, !digitalRead(29)); //// D--RELAY B2
      }
/*      
      if (c == 69 ) {
        digitalWrite(37, !digitalRead(37)); //// E--
      }

      if (c == 70 ) {
        digitalWrite(39, !digitalRead(39)); //// F--
      }
*/
      if (c == 71 ) {
        digitalWrite(31, !digitalRead(31)); //// G--RELAY C1
      }

      if (c == 72 ) {
        digitalWrite(33, !digitalRead(33));  //// H -- RELAY C2
      }

      if (c == 73 ) {
        digitalWrite(43, !digitalRead(43));  //// I --
      }

       if (c == 74 ) {
        digitalWrite(35, !digitalRead(35));  //// J --
      }

       if (c == 75 ) {
        digitalWrite(37, !digitalRead(37));  //// K --
      }

      if (c == 76 ) {
        digitalWrite(39, !digitalRead(39));  //// L --
      }
      if (c == 77 ) {
        digitalWrite(41, !digitalRead(41));  //// M --
      }
      if (c == 78 ) {
        digitalWrite(35, !digitalRead(35));  //// N --
      }

    }
    count++;
    // Serial.print(count);
    Serial.println("");
    digitalWrite(13, false);
  }
}
</code></pre>

<p>My new driver is came, I just scare to use it, heard that DC motor will draw upto 300A at the start, what should I do to reduce the start current? </p>
 34529: <p>As you wrote in comment you use this H bridge:</p>

<p><a href="https://www.ebay.com/itm/60A-DC-Motor-Driver-Module-High-Power-motor-Speed-Control-Dual-Channel-H-bridge/122479397950" rel="nofollow noreferrer">https://www.ebay.com/itm/60A-DC-Motor-Driver-Module-High-Power-motor-Speed-Control-Dual-Channel-H-bridge/122479397950</a></p>

<p>The description how to use it is clear:
<a href="https://i.stack.imgur.com/s5fTz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s5fTz.png" alt="h-bridge features"></a></p>

<p>But the listing doesn't say what will happen when you set state of <code>A1,A2=1.1</code> to that H-bridge.</p>

<p>When you set value of <code>A1,A2=1.1</code> to a unprotected (cheap) H-Bridge you get a direct short to ground through 2 transistors burning them instantly</p>

<p><a href="https://i.stack.imgur.com/YQiz5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YQiz5.png" alt="H-Bridge and electricity path for 1,1"></a></p>

<p>Your code actually does not protect against that:</p>

<pre><code>   if (motor == 1) {
    digitalWrite(AIN1, direction);
    digitalWrite(AIN2, !direction);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, !direction);
    digitalWrite(BIN2, direction);
    analogWrite(PWMB, speed);
  }
}
</code></pre>

<p>If previous value of direction is 0 (<code>A1,A2=0,1</code>) and you want to set direction to 1 (<code>A1,A2=1,0</code>) when arduino runs the line <code>digitalWrite(AIN1, direction);</code> for few cycles you actually end up with <code>A1,A2=1,1</code> and MOSFETs go bye bye.</p>

<p>Try setting AIN1, AIN2 (or BIN1, BIN2) to 0 before adjusting the direction</p>

<pre><code>   if (motor == 1) {
    digitalWrite(AIN1, LOW);
    digitalWrite(AIN2, LOW);

    digitalWrite(AIN1, direction);
    digitalWrite(AIN2, !direction);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, LOW);
    digitalWrite(BIN2, LOW);

    digitalWrite(BIN1, !direction);
    digitalWrite(BIN2, direction);
    analogWrite(PWMB, speed);
  }
}
</code></pre>

<p>This way you are guaranteed that you always have at least one <code>0</code> there.</p>

<p><strong>EDIT:</strong></p>

<p>You wrote that the module contains IR2103s it should protect you from the problem I described above. (But my suggested fix is not dangerous so you can use it just in case)</p>

<p>There is another possibility. Maybe the rapidly changing of the direction induces high voltage spikes in the motor, and that burns the circuit. Do you see any power diodes there? Look at the image I pasted above it has 4 diodes that should safely discharge those spikes. Make sure your code does not change direction every few milliseconds.</p>
