unfortunate crash of arduino

i am trying to make a bluetooth rc car. i connected my circuit as below
but unfortunately when i connect the battery it doesn't start.Even after removing all the wires and reconnecting it to battery it does not start.When i connected it to the pc the ON led lights up for a few second and goes down and arduino get started heating up rapidly.
what to do?

If there is an Arduino program involved in the project please post it. And please use the code button </> so your code looks like this and is easy to copy to a text editor

...R

code invloved is:-

#define in1 5 //L298n Motor Driver pins.
#define in2 6
#define in3 10
#define in4 11
#define LED 13
int command; //Int to store app command state.
int Speed = 204; // 0 - 255.
int Speedsec;
int Turnradius = 0; //Set the radius of a turn, 0 - 255 Note:the robot will malfunction if this is higher than int Speed, if it is, pin13 will be HIGH. Useful for debugging.
void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(LED, OUTPUT); //Set the LED pin.
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop() {
  if (Serial.available() > 0) {
    command = Serial.read();
    Stop(); //Initialize with motors stoped.
    switch (command) {
      case 'F':
        forward();
        break;
      case 'B':
        back();
        break;
      case 'L':
        left();
        break;
      case 'R':
        right();
        break;
      case 'G':
        forwardleft();
        break;
      case 'I':
        forwardright();
        break;
      case 'H':
        backleft();
        break;
      case 'J':
        backright();
        break;
      case '0':
        Speed = 100;
        break;
      case '1':
        Speed = 140;
        break;
      case '2':
        Speed = 153;
        break;
      case '3':
        Speed = 165;
        break;
      case '4':
        Speed = 178;
        break;
      case '5':
        Speed = 191;
        break;
      case '6':
        Speed = 204;
        break;
      case '7':
        Speed = 216;
        break;
      case '8':
        Speed = 229;
        break;
      case '9':
        Speed = 242;
        break;
      case 'q':
        Speed = 255;
        break;
      case 'X':
        Auto();
        break;
      case 'x':
        Manual();
        break;
    }
    Speedsec = Turnradius;
  }
}

void forward() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speed);
}

void back() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speed);
}

void left() {
  analogWrite(in3, Speed);
  analogWrite(in2, Speed);
}

void right() {
  analogWrite(in4, Speed);
  analogWrite(in1, Speed);
}
void forwardleft() {
  analogWrite(in1, Speedsec);
  analogWrite(in3, Speed);
}
void forwardright() {
  analogWrite(in1, Speed);
  analogWrite(in3, Speedsec);
}
void backright() {
  analogWrite(in2, Speed);
  analogWrite(in4, Speedsec);
}

void backleft() {
  analogWrite(in2, Speedsec);
  analogWrite(in4, Speed);
}

void Stop() {
  analogWrite(in1, 0);
  analogWrite(in2, 0);
  analogWrite(in3, 0);
  analogWrite(in4, 0);
}

void Auto() {
  // for future use
}
void Manual() {
  // for future use
}

The diagram shows a 9V battery powering an UNO, two motors and a bluetooth board. You've got the 9V battery directly connected to the +12V input on the motor board. Surely that should be a clue that you've done something wrong?
The 9V battery is not enough to power the UNO on its own for very long, never mind two motors.

You need a 12V power supply for the motor board - I don't know how much the motors need but I suspect the supply should be capable of at least 1 amp and, more likely, 2A. That supply can also be used as input to the UNO.

Pete

even when the motors are not connected, arduino doesn't work when connected to battery.
Can you tell me for what Vin is used.

sashakt:
even when the motors are not connected, arduino doesn't work when connected to battery.
Can you tell me for what Vin is used.

Does the Arduin work when it is connected to your PC via the USB cable ?

If by "battery" you mean a PP3 type of 9v battery you should assume that is the problem. Try a pack of 6 or 8 AA cells.

...R

The way you've attached your motor controller may destroy your Arduino. An Arduino can't safely sink more than 400 mA over all of the gnd pins combined on the board (200 mA per). Since your controller is only attached to one ground pin, 200 mA is your limit. If your motor controller tries to sink more than that, you may destroy your Arduino. Never draw high amperage through the Vin pin, and never sink high amperage to the Gnd pins.

See here for limitations.

Edit: I was mistaken with the above. The limit for the Arduino's external GND pins is not specified anywhere that I can find. But it may be around 2A. That is apparently what the PCB's traces can handle according to this document.

You won't be able to operate motors for very long on a 9V battery. It's not just the low mAh, but also the high effective series resistance of most 9V batteries.

I suggest using 12V worth of AA batteries instead, as a start... but still don't expect them to operate a pair of motors for more than a half hour to an hour. Ultimately LiPo is a good choice but then you have to worry about how you're going to avoid draining a LiPo so much that it is damaged.

An Arduino on its own (no motors) should run on a 9V battery for a very long time. But once you start adding anything that draws more than a few mA, battery life for a 9V drops rapidly.

What part of the Arduino is getting hot? It has a resettable fuse (polyfuse) that is designed to get very hot (that's how it works) if you have a short between Vin and GND. Might be worth checking to see if that's the case.

According to your schematic, your battery is correctly attached to the Arduino. However, you are bypassing the reverse polarity protection diode so you have to be very careful. Accidentally connecting a 9V battery backwards to the Gnd and Vin pins, even for a moment, can destroy your Arduino. A safer way is to attach the 9V battery to the DC power jack using a 9V battery clip to center-positive DC barrel jack adapter. Only wire batteries up directly to the Vin/gnd pins if you there is no risk of connecting them backwards, or if you're using your own reverse polarity protection circuit.

It kind of sounds like your Arduino is toast. But don't assume that quite yet.

Disconnect everything and plug your completely bare Arduino in to the PC and let us know what happens. Try uploading the "Blink" example sketch from the Arduino IDE (under Examples->Basics) and see if it works. If that works, your Arduino is probably fine. If that doesn't work, it's probably toast.

The good news is that, if you've blown the ATMega328P chip and not damaged anything else, and assuming it's a socketed DIP, you can fix it by purchasing a new chip (a few dollars) instead of having to buy a whole new Arduino. If you've damaged another part of the board, but the chip is fine, you might consider following this guide to put that chip to use on some breadboard.

Rylee_Isitt:
The way you've attached your motor controller may destroy your Arduino. An Arduino can't safely sink more than 400 mA over all of the gnd pins combined on the board (200 mA per). Since your controller is only attached to one ground pin, 200 mA is your limit. If your motor controller tries to sink more than that, you may destroy your Arduino. Never draw high amperage through the Vin pin, and never sink high amperage to the Gnd pins.

Not true.
You confuse circuit board pins with Atmega chip pins.
Leo..

Leo,

The document I linked to seemed quite clear to me but now I have my doubts. The main heading is "ARDUINO PIN CURRENT LIMITATIONS". Later on, a subheading appears "ATMEL ATMEGA328 (UNO and Duemilanove) Current Specifications". Very confusing IMO.

The Vin and Gnd pins must have limits. Even though both external GND pins are connected dirrectly to the DC barrel jack's GND, it still has a current limit that depends on its cross sectional area.

The Vin pin is behind a reserve polarity protection diode (M7) with a 1A limit, and that's something I only discovered after looking at the Arduino board's schematic and then looking up the diode's specifications. Things like this need to be made more clear.

Does anyone have a source for the current limits Arduino's external GND pins?

Maybe some of the wording on that page is confusing.
The whole page is about the actual MCU chip.

There are ofcourse also current limitations of the board.
e.g. DC socket to Vin should be kept well under 1Amp, because of the limitation of the reverse protection diode.
The rest is mostly common sense.
Leo..

Leo,

Yes, very confusing. I don't buy Arduino boards so I can pop the MCUs off and throw the boards away. I can see that the guide is applicable to the I/O pins, so I understand why it's being provided, but if a person goes there wanting to know about the Arduino's power pins, good luck to them.

Turns out the GND traces seem to have a 2A limit, if we assume that the traces are the same cross-sectional area as those used in the Vin line (read the description about the Vin pin).

Since the reverse polarity protection diode is being skipped in this case, it's actually that 2A limit that rules the day.

Rylee_Isitt:
Turns out the GND traces seem to have a 2A limit, if we assume that the traces are the same cross-sectional area as those used in the Vin line (read the description about the Vin pin).
Since the reverse polarity protection diode is being skipped in this case, it's actually that 2A limit that rules the day.

Did a quick calculation of the ground track between DC jack and the two ground pins near the 5volt pin of a Mega.
Current capability of those 50mil tracks is more than 7Amps.
Vin and 5volt are the same width.

AFAIK, the reverse protection diode on most boards is a 1N4004.
That makes it 1A max (stinking hot).
Leo..

Hmm, 7 Amps is a quite a lot, so that's good. It seems very unlikely he fried his board that way, then.

We'll have to wait for a reply to see if the board works on its own. Sounds like something's wrong, though, the circuit looks OK apart from a 9V battery being (potentially) too weak for a pair of DC motors.

Is there a way for a part to fail in a closed state (eg, a diode breaking down) that will cause a permanent short? As far as I know most of the heat produced should be either the regulator, which isn't be used here, or the polyfuse, which is a sign that something is shorted out.

sashakt:
When i connected it to the pc the ON led lights up for a few second and goes down and arduino get started heating up rapidly.

With "Arduino" you mean the chip itself.

With nothing connected to the board, and the "blink" sketch loaded, and on USB power, the MCU should not heat up.
If it does, the chip is toast.
Sharing motor power with the Arduino is never a good idea, and a 9volt battery could make things worse.
Leo..

yes the arduino is working correctly, i have tried examples after that on it but this project is not working.Even when i dissconnect the motor from motor driver it is unable to start.

guys, i can send you a video on whatsapp showing all the steps i did.

it is working propery when power is given through pc but not when given through pp3 9V battery.

sashakt:
it is working propery when power is given through pc but not when given through pp3 9V battery.

Did you read the second part of Reply #5?

...R

how much ampere can arduino support.

You appear to be connecting a 9 v battery directly to the vin supply of the uno .

The regulator is bypassed as far as the motors are concerned but you will still have the problem of too much current draw dropping the terminal voltage of the battery and too large a curent through the ground traces could cause strange effects due to ground potential.

have you measured the battery voltage under load ? without the motors connected.

Sorry for the edit , it should have been a draft.