From the course: Learning Arduino: Interfacing with Analog Devices
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Understanding pulse-width modulation (PWM) - Arduino Tutorial
From the course: Learning Arduino: Interfacing with Analog Devices
Understanding pulse-width modulation (PWM)
- [Instructor] Pulse with Modulation or PWM simulates an analog output signal using a digital signal. Let's see how it works. We know that the digital values are zero or one. So they are either low or high. The pulse with modulation technique controls the amount of time a digital output toggles between high and low values. This is called the duty cycle of the signal. So this is a 0% duty cycle. This means that the digital output is always at the low-level. With a 20% duty cycle the high is kept on for 20% of the total period. When the duty cycle is 50%, the high value is applied half of the time, so it's on for half of the period. The same principle applies when having 70% duty cycle and 100% duty cycle, where the digital output is always high. The duration of the on time is called the pulse width. To get varying analog values, you change or modulate that pulse width. The length of the duty cycle determines the simulated analog voltage generated by the digital interface. The longer…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
How Arduino generates analog output1m 4s
-
(Locked)
Understanding pulse-width modulation (PWM)2m 8s
-
(Locked)
Understanding the analogWrite function with PWM1m 19s
-
(Locked)
Wire up an LED1m 5s
-
(Locked)
Write code to use PWM with the LED1m 56s
-
(Locked)
Understanding the map() function1m 45s
-
(Locked)
Wiring a potentiometer to control LED1m 13s
-
(Locked)
Coding to control the LED with a potentiometer3m 42s
-
(Locked)
-
-
-