Introduction to Physical Computing / Week 4 / Analog Output
Microcontrollers generally can’t produce a varying voltage. They can only produce digital voltage, which is either HIGH or LOW. So, to emulate the effect of analog output, the microcontroller generates a series of voltage pulses at regular intervals. This is called pulse width modulation (PWM). Analog outputs can be used for many purposes such as fading an LED, controlling a motor or speaker.
As part of the first lab, I tried to feed an analog input into the Arduino from a potentiometer, and then use the input to regulate the brightness of a LED. The results were are as shown below:
Similar to an LED, one can use the analog input provided by the potentiometer to control other devices such as servo motors or speakers. Next, I worked with a speaker where I noticed that just changing the pulse width only produced a variation in the speaker’s volume. Through the Arduino Uno, one can also vary the frequency of the pulse width, which can be used to vary the sound produced by the speaker. This is done using the tone() function.
I used a servo motor that had the capability to turn 180 degrees.