Without an external digital to analog converter circuit, getting pulse width modulation out of more than a single PWM pin on the Raspberry Pi could be achieved by writing your own code to set the pins high and low at the appropriate time (i.e. bitbanging). The solution isn’t perfect, however. Since you’re sharing the CPU of the Raspberry Pi with other processes that are running simultaneously, you can’t rely on getting the clock cycle you need to change the state of the pin at just the right time. This means that pulsing pins for fading LED effects, mixing colors with RGB LEDs, or controlling servos will have unexpected effects.
Thomas Sarlandie from TB Ideas needed PWM for a project but didn’t have the time to wait for the circuitry he needed. While exploring his options with software PWM, he came across ServoBlaster, which cleverly offloads the task of switching the pins to the direct memory access (DMA) controller. Since ServoBlaster was meant for controlling hobby servo motors using pulses, it didn’t give Thomas the full 0 to 100% PWM control he sought. After making some adjustments to the code, he had what he wanted: PWM control on the GPIO pins of the Raspberry Pi. His code, pi-blaster, is now available to all of us so that we can pulse the pins on our Pis all we want! [via Hack A Day]