Light Sculpture: Pulse Width Modulation #2

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.

Main Functions

  1. In the definition of setup, set all LED pins as OUTPUT and knobPin as INPUT using the function named . (hint: It's just the name).
  2. In loop, call a function named pwmUsingKnob using the statement .

Knob Functions

  1. In the Knob Functions section, open the definition of pwmUsingKnob(a void function with no parameters) with the statement .
    1. Inside this function: Assign the int variable onTime to be the return value of the function getOnTimeUsingKnob() using the statement .
    2. Assign the int variable offTime to be the remnant of pwmPeriod after onTime using the statement .
    3. Blink all LEDs using the values you've calculated and your Helper Functions.
      1. Use the statement to turn on all of the LEDs.
      2. Use the statement to wait.
      3. Use the statement to turn off all of the LEDs.
      4. Use the statement to wait.
Back Next Page