Binary Code Modulation (BCM) it's an amazing method of controlling led brightness and was invented by Artistic Licence. It's like PWM but not really. The main advantage over PWM is the low CPU usage regardless of how many leds it controls.
This library provides a fast implementation of Binary Code Modulation useful for controlling RGB leds and dimming multiple leds for creating animations like led cubes. A complete cycle takes only 8 timer interrupts and each interrupt takes only 4us on a 8MHz CPU. The leds can be on different ports.
How Binary Code Modulation (BCM) works and how it differs from PWM
To dim a led with PMW is simple. If you want the led to be half as bright you turn the led on for 50% of the cycle and 50% for the other half. Or 20% on and 80% off for an even dimmer led.
Bit Angle Modulation uses the weight of each bit in a binary number. For example in one byte there are 8 bits with numbers from 0 to 7. Bit 0 is called the Least Significant Bit (LSB) and it's weight is 1. Next bit 1 has a weight of 2, bit 2 has a weight of 4, then 8, 16, 32, 64 and 128. Bit 7 is called the Most Significant Bit (MSB) because it has the highest weight - 128.