The document discusses different methods for implementing pulse-width modulation (PWM) on an Arduino board. It explains that PWM involves generating a digital square wave where the duty cycle, or time the signal is on, can be varied between 0-100% while maintaining a constant frequency. The Arduino makes PWM easy to use through the analogWrite function, which sets the duty cycle for pins capable of PWM output. More advanced techniques allow direct control over the duty cycle and frequency by accessing the PWM registers.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
47 views2 pages
PWM Examples: The Original Document
The document discusses different methods for implementing pulse-width modulation (PWM) on an Arduino board. It explains that PWM involves generating a digital square wave where the duty cycle, or time the signal is on, can be varied between 0-100% while maintaining a constant frequency. The Arduino makes PWM easy to use through the analogWrite function, which sets the duty cycle for pins capable of PWM output. More advanced techniques allow direct control over the duty cycle and frequency by accessing the PWM registers.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
by Ken Shirriff
with further editing by Paul Badger
the original document Pulse-width modulation (PWM) can be implemented on the Arduino in several ways. This article explains simple PWM techniques, as well as how to use the PWM registers directly for more control over the duty cycle and frequency. This article focuses on the Arduino Diecimila and Duemilanove models, which use the ATmega168 or ATmega328. If you're unfamiliar with Pulse Width Modulation, see the tutorial. Briefly, a PWM signal is a digital square wave, where the frequency is constant, but that fraction of the time the signal is on (the duty cycle) can be varied between 0 and 100%.
PWM examples PWM has several uses:
Dimming an LED
Providing an analog output; if the digital output is filtered,
it will provide an analog voltage between 0% and 100% .
Generating audio signals.
Providing variable speed control for motors.
Generating a modulated signal, for example to drive an
infrared LED for a remote control. Simple Pulse Width Modulation with analogWrite The Arduino's programming language makes PWM easy to use; simply call analogWrite(pin, dutyCycle), where dutyCycle is a value from 0 to 255, and pin is one of the PWM pins (3, 5, 6, 9, 10, or 11). The analogWrite function provides a simple interface to the hardware PWM, but doesn't provide any control over frequency. (Note that despite the function name, the output is a digital signal, often referred to as a square wave.) Probably 99% of the readers can stop here, and just use analogWrite, but there are other options that provide more flexibility.