Dimmer Effect

Analog Output

Let's improve the Basic LED project by introducing a dimmer effect:

Note that the LED is not turning on and shutting off instantly, but rather slowly getting brighter and then dimming out.

Digital Signals:

These are binary discrete states.

Analog Signals:

Credit: https://www.researchgate.net/figure/Analog-vs-Digital-Signal_fig21_288180515

We need an Analog output signal to drive a dimmer effect through the LED.

Analog I/O on Arduino

Let's take a look at the Arduino board:

Note that the bottom left area is for Analog inputs. It's not obvious where the Arduino can send out an Analog output signal, like the one we'd need to make an LED dimmer effect.

So, how can we control brightness on the LED?

Pulse Width Modulation (PWM)

PWM is an efficient method for varying and controling power.

It is used in all sorts of electrical systems:

We can only turn On/Off digital outputs from 0v to 5V.

But, what if we wanted %50 power?

Making a PWM digital signal:

This is a %50 Duty Cycle.

How about other duty cycles? %25? %75? %96?

So, at %25 PWM output, the LED should be ~1/4 as bright as when it's on %100 PWM (simple digital ON), and so on...

NOTE: The reason it looks dim rather than just blinking is because the duty cycle period we chose was 1ms. If we choose something bigger, on the order of 33ms or 30Hz - that is closer to what our eyes can distinguish as different states... 30 Frames Per Second sounds familiar?

Normally the duty cycle for PWM is on the order of tens of micro-seconds or 100,000Hz.