Signal Analysis: Analog V.S. Digital PWM!!
Tuesday, November 18th, 2008Signals come in two basic types – Analog and Digital. Analog signals are capable of being any value, where Digital signals are called “discrete”, meaning they capable of being in only one of two states! The terms for these two states of a Digital signal are varied but include; ON/OFF, TRUE/FALSE, 1/0, HIGH/LOW, etc.
So what’s that mean? A good example of a Digital signal is a light switch in your house. You can either flip the light switch ON, or flip the light switch OFF. To follow this line of thought, an example of an Analog signal would be a light with a dimmer switch. With a dimmer switch you can adjust how bright or dim the light is, anywhere from completely OFF, to completely ON.
Okay… The Arduino is capable of analog and digital INPUT, but only capable of digital OUTPUT. When working with the Arduino we see that there are 6 analog pins and 14 digital pins. (It should be noted that if you have no need of analog INPUT; you may use the analog pins as extra digital OUTPUT pins — declaring them as digital pins 14 – 19)
So, if we are only capable of digital OUTPUT on the Arduino, how are we able to dim a LED?
ENTER PWM!! (Pulse Width Modulation) Some, but not all pins on the Arduino are capable of Digital PWM OUTPUT. Basically, PWM is the digital way of mimicking an analog OUTPUT.
To better show the difference between Analog and Digital PWM, I put together a simple LED dimmer circuit and hooked up an oscilloscope to view the Analog and Digital PWM signals. I took some video of everything in action to better serve as an example.
Analog Signal VS PWM Signal from Morgellon on Vimeo
The sketch I used in this video is available here: http://serverwillprovide.com/icuubi/examples/analog_vs_PWM.pde

