Arduino for Beginners · Analog Signals: ADC and PWM
PWM and analogWrite() — dimming an LED
Analog Signals: ADC and PWM
Introduction
Lessons 5.1 and 5.2 showed how to READ an analog signal with analogRead(). Now we reverse the direction: how to OUTPUT a "near-analog" voltage on a pin. The Uno has no true digital-to-analog converter (DAC), so it fakes an intermediate voltage with PWM (Pulse Width Modulation) — switching a digital pin on and off very fast. You will learn analogWrite(pin, value) with its 0-255 range, the concept of duty cycle, which Uno pins carry PWM (3, 5, 6, 9, 10, 11) and how to smoothly dim an LED with a for loop. This is the foundation of controlling LED brightness, motor speed and sound tones.