From the course: Learning Arduino: Pulse Width Modulation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Matching PWM and non-PWM LED brightness

Solution: Matching PWM and non-PWM LED brightness - Arduino Tutorial

From the course: Learning Arduino: Pulse Width Modulation

Start my 1-month free trial

Solution: Matching PWM and non-PWM LED brightness

All right, let's take a look at the solution for this challenge. LEDs need approximately 3 volts before they begin to glow, which is why I had you calculate, but not test, values one through four. Analog write values between zero and 100 will produce little to no light from most LEDs. The first value is 26. 26 divided by 256 is .1, so the duty cycle is 10%. My A value should be 10% of the total delay. If A is one, then B could be nine. This would produce a wave that is high 10% of the time. The second value is 64. 64 divided by 256 is .25, so the duty cycle is 25%. If A is one, then B could be three, producing a wave that is high 25% of the time. The third value is 80. 80 divided by 256 is .31, so the duty cycle is 31%. If I say A should be three, then B could be seven, producing a wave that is high 30% of the time. The fourth value is 105. 105 divided by 256 is .37, so the duty cycle is 37%. If A is two, then B should be three, producing a wave that is high 40% of the time. Remember,…

Contents