I bought an arduino mega, just started with a few leds and toggle switches but i'm planning to use all the available ports with different components, once I get enough skill.
My doubts are, how to know if the USB is able to provide enough power for my current setup?
And more important, what could happen at worst?
The USB port may get damage I guess, but also the board and the components connected there?
Rookie2:
My doubts are, how to know if the USB is able to provide enough power for my current setup?
You need to know in advance what the voltage and current requirements are for anything you connect to the Arduino, and ensure it is compatible with what you're connecting it to. While you are unlikely to damage the USB itself, it is very easy to damage the Arduino output pins by connecting something that draws too much current from it.
rweber95:
I think a USB port device is limited to 0.5 A at 5 VDC.
0.5 for USB 2.0 and 0.9 for 3.0
PeterH:
You need to know in advance what the voltage and current requirements are for anything you connect to the Arduino
Actually the .5amp 5vdc limit is enforced with a on-board 500ma thermofuse on the arduino board, so the limit applies to both USB 1,2, or 3. Note that if you are powering the board via the arduino external power connector then you can draw a little more current then the 500ma USB limit, depending on the actual voltage applied to the external power connector or Vin pin.
Lefty
I guess so, I could also use an Amperemeter connected in series with the +5v line of the USB cable, right?
Does this means that with 6 or 7 leds I would be reaching the limit of the board?
Also the Mega documentation says each port delivers only 40ma so I don't get it.
Yes but it's the max average forward current that will determine what you run your leds at. 20ma is
the current limit you should use for these leds set by the size of a series current limiting resistor between each output pin and the led.
Does this means that with 6 or 7 leds I would be reaching the limit of the board?
Also the Mega documentation says each port delivers only 40ma so I don't get it.
Each pins has an absolute max 40ma rating, and 30ma pin output current or less is safer value
to run the output pins at. So 7 leds running at 20ma is 140ma total, which is well within the boards +5vdc current capacity and each output pins rating.
The key is it is up to you to manage the total current requirement for the complete project. If driving standard 20ma leds you do that by proper sizing of the current limiting resistors you have to have between the output pins and the leds.
Lefty
So, according ohm's law and as i'm using 1K resistors..
I = V/R
5/1000 = 0.005
Are my leds using 5ma each?
Am I right?
Almost, you have to factor in the forward voltage drop of the leds you are working with. Your blue leds have a, lets call it a 3.5 Vf rating. So the V to use in your formula is Vcc (+5vdc) - Vf (3.5vdc), So with a 1k ohm resistor the current value will be 1.5ma, which is pretty dim but usable.
If you want to solve for the resistor size that will limit current to 20ma then R= (5-3.5)/.02 = 75 ohms.
Rookie2:
I guess so, I could also use an Amperemeter connected in series with the +5v line of the USB cable, right?
Current over the USB interface is not likely to be the limiting factor, and in any case by the time you've measured the actual current it's a bit late to be thinking about whether you've just overloaded something, isn't it?
You need to read and understand the electrical spec of whatever it is that you're planning to connect, to ensure that it will not damage or be damaged by the Arduino.