First, let's say we work with these two functions:

\$L(n)\$ is the maximum amount of LEDs that can be driven from \$\mathsf{n}\$ pins.

\$p(n)\$ is the minimum amount of pins needed to drive \$\mathsf{n}\$ LEDs.

## 1:1-method

This one is easy:

$$L(n)=n$$

$$p(n)=n$$

## A diode matrix

At first, we need to determine the most efficient diode matrix. For example, you could divide 4 pins into two sets of 2, or one set of 1 and one of 3. Obviously, the amount of LEDs is given by \$\mathsf{length\cdot{}width}\$. We can say \$\mathsf{width=n-length}\$, so the amount of LEDs is: \$\mathsf{length\cdot{}(n-length)=-length^2+n\cdot{}length}\$. Given an \$\mathsf{n}\$, this is a parabola, which has a maximum when \$\mathsf{length=\frac{n}{2}}\$. You can also do this on gut feeling. So, the maximum amount of LEDs is reached when the two sets have an equal amount of pins, or differ only 1, in case of an odd number of pins. We can now say:

$$L(n)=\lfloor{}\frac{n}{2}\rfloor{}\cdot\lceil{}\frac{n}{2}\rceil{}$$

Also, we can now easily understand the function \$\mathsf{p(n)}\$:

$$p(n)=
\begin{cases}
1&\text{ for }n=1\\
\lceil{}\sqrt{n}\rceil&\text{ for }n\gt1
\end{cases}$$

I just included the cases for 1, as this is a special case. Normally, you can just use the second function.

## Charlieplexing

In this method, we have two LEDs between every set of two pins. We can calculate the amount of sets of two pins with:

$$(n-1)+(n-2)+\dots+1 = \frac{n\cdot(n-1)}{2}=\frac{n^2-n}{2}$$

Now we can say that:

$$L(n)=2\cdot\frac{n^2-n}{2}=n^2-n$$

We saw that the amount of pairs of pins equals \$\mathsf{n\cdot(n-1)}\$. With some reverse thinking, this leads to:

$$p(n)=
\begin{cases}
1 &\text{ for } n=1\\
2\cdot\lfloor\sqrt{n}\rfloor-1 &\text{ for } n\gt1
\end{cases}$$

I just included the cases for 1, as this is a special case. Normally, you can just use the second function.

## Other methods

I'm not aware of any other methods, as of Tuesday march 12, 2013.

It's right there, in section 21. See it?

\$\frac{0.25\text{V}}{10\text{mA}}= 25\Omega\$

\$\frac{5\text V - 4.75\text{V}}{10\text{mA}}= 25\Omega\$

Therefore yes, the output has a resistance of 25\$\Omega\$ at 25\$^{\circ}\$C.

## Best Answer

In the root of the expression, it is "set the bit high/low (=1/0)"

It usually means set the corresponding pin "high logic level" and "low logic level", accordingly.

You would have to consult the documentation of your microcontroller, but it almost always is "set the output voltage to Vss/Vdd" (VssIO/VddIO if your micro has separate IO and core power supplies).