Light Sculpture: Pulse Width Modulation #4

Home

Current Objective: Visible Pulse Width Modulation

  1. Read the potentiometer knob voltage using analogRead
  2. Modulate the duty cycle (onTime) of the LEDs using the knob voltage.

Requirements

  1. Cleanly format your code to maximize organization and readability like the dpeaArduinoStyleGuide.
  2. Clarify the purpose of each function and variable through smart naming.
  3. Use headers and comments as needed to enhance organization.

Pulse Width Modulation (Fading!)

  1. Now it's time to speed up the PWM by 1000x so that the LEDs fade.
  2. Replace each delay with delayMicroseconds in the function pwmUsingKnob.
  3. This delays in microseconds (1/1000000 of a second) rather than milliseconds (1/1000 of a second).
  4. The statement after turning on the LEDs is now .
  5. The statement after turning off the LEDs is now .
  6. Test your code and observe the LEDs now blinking faster than the eye can see, appearing to fade.

Check Your Understanding

  1. The process of modifying the on time and off time while keeping the period constant is called (write out the full name, not the abbreviation, and capitalize the first letter of each word).
  2. The function to get the knob voltage is .
  3. Switching from delay to delayMicreconds increases the speed times (write as a number with no symbols).
Back