Need help with LED math

im making my first string of leds using 13 PL9823 RGB leds with integrated chips so i can program them with only one Arduino pin. i already solder them on parallel circuit.

I know from the datasheet that they need 5.5v and 20mA to run properly. Since Arduino only throws 40mA max per pin, im assuming it wont be enough to power the 13 leds right? to my surprise, when i plugged them directly to the 5v pin on the arduino they work fine.

i have some questions

A-Why are they working fine since the arduino’s output is 40mA max? how to calculate how much current i need for the 13 leds?
B-I tried to put a 100oms resistor between the 5v and the leds but it made the leds work wrong, randomly blinking. Are the leds in danger because im not using a resistor?
C-if i want to power them with a 9v Battery, how can i lower the voltage so the leds receive only 5.5volts?

thank you very much!

PL9823 leds Datasheet

You have addressable leds; the datapin does not draw 40 mA or 10 mA but a fraction of 1 mA (could not find it in the datasheet).

The 5V output of the Arduino (which model) can deliver more than 40 mA; no idea how much exactly (see below). The 40 mA limit is for data pins.

If you feed the Arduino from the USB, the current limit is the current that the USB port can deliver (500 mA). If you feed it from Vin or the barrel, it's the current that the voltage regulator on the Arduino can deliver without overheating.

...I'm not familiar with that LED and in my quick-search I didn't find a full datasheet (I don't know the current-rating, etc.).

The 40mA limitation is for I/O "signal" pins, not the 5V power pin.

You're probably OK... The amount of current you can get from the 5V pin depends on how you are powering the Arduino (USB or some other 5V source, or a higher voltage through the regulator).

If you're using the regulator, it's a combination of current and voltage dropped across the regulator. A rule-of-thumb is that if a semiconductor is too hot to hold your finger on, it's dissipating too much power and it might burn-up. (The voltage regulator is U1 on an Arduino.)

C-if i want to power them with a 9v Battery, how can i lower the voltage so the leds receive only 5.5volts?

Use a voltage regulator. There are LOTs of voltage regulator chips, but for 5.5V you'll need an "adjustable" regulator. That doesn't mean your finished design is adjustable, but the voltage will be determined by a resistor ratio.

You may not get much life from a 9V battery. Linear voltage regulators (the LM317 chip is a popular example) are inefficient and with 4V dropped across the regulator and 5V to the load, the voltage regulator is consuming/wasting almost as much power as the thing it's powering. Switching regulators are more complicated an nearly 100% efficient.

On the other hand, with 9V regulated-down to 5V the battery can get drained-down past it's normal-useful life to around 6V and you'll still get 5V out of the regulator.

According to the badly translated data sheet, you do not need resistors. A standard 9 volt battery will not provide sufficient current. IF the LEDs used 20 mA, you would need to provide 13 x 20 mA = 260 mA. HOWEVER, the test conditions in the data sheet are 20 mA PER COLOR. FURTHERMORE, the data sheet worst case is 100 mA PER LED. 13 x 100 mA = 1.3 amps! This is a lot of current for most Arduinos. Fortunately, this worst case probably only occurs for a short time at initial power up. If all LEDs are at full brightness white, figure 13 x 60 mA = 780 mA.

Good Luck completing this project without any electrical design knowledge!