Just starting out with electronics, still scared to fry something :
I have the arduino mega and its datasheet says you are allowed to pull a maximum of 40mA on any output pin. Is this limit also for the 5v and vin pins? because i want to connect a 4x16 LCD that uses a backlight which uses about 60~75mA
No, the 40ma doesn't apply to the +5V pin (or the Vin pin). They can handle more than that.
I wouldn't use the Vin pin though, because its voltage depends on how the board is being powered.
Additionally you should ALWAYS limit the current to a LED (including the backlight on the LCD display) by putting a resistor in series with the LED. To neglect that risks blowing the LED! Experiment with resistors in the 10 ohm to 33 ohm range.
Adding a resistor will drop the current somewhat and reduce the brightness somewhat but you will be amazed at how little the perceived brightness will decrease even if you limit the current to just a few (say 10-20) ma or even less. I use a 22 ohm resistor with mine and it's plenty bright. The current is about 15 ma and can easily be supplied by one of the Digital pins.
Note that a LCD backlight is several LEDs in series which give them a voltage drop of about 4.2 volts meaning you only have about 0.8 volts to drop across the resistor. That's why such a low value resistor is used.
Single LEDs (the common red, green etc ones) require a higher value resistor typically in the 470 ohm to 4k range to limit the current to a safe value.
To be honest, I have always run lcd's backlights directly
from my 5v lines, powered by the arduino 5v pin. No issues or overheating, so I'm betting the people who made the LCD thought it was a good idea to stick a resistor on the backlight power pin of the LCD. Your LCD probably has the same feature, but it really depends on the LCD itself in the end.
You supply a voltage within the range on the datasheet and the Arduino will draw the amount of current it needs as long as your power supply can output that much.
I currently power a backlit LCD display from the 5V on an Arduino 2009. I had the same concerns, monitored the temperature of the regulator with my fingertip and found nothing out of the ordinary.
I would recommend if you do the same thing with a Boarduino, to put a heatsink on the Voltage Regulator as it runs quite warm without it.
The difference between the two is that the Boarduino is running a TO-220 case voltage regulator bare, which has sufficient heat radiation for just the processor, more load requires a heatsink. The Arduino is running a surface mount version that sinks to the copper in the PC board it's mounted to.
If it is not already mounted, your LCD display should have pads to include a current limiting resistor, check the spec sheet for values.
I finally managed to get the display working, the library included with arduino works great! now its time to figure out how to create my own library, fun!
I have LCD displays from 4 different manufacturers on hand. NONE of them have on-board dropping resistors and all rate the LEDs at from 3.5 to 4.2 volts forward voltage.