Introduction
- Write and test code as you go. This quiz is the guide. You must turn in your code
- Refer frequently to the dpeaArduinoStyleGuide. Your architecture should follow the formatting shown there.
Setup
- Watch the following video on Pulse Width Modulation (PWM),stopping at 0:59 (one minute). Note that the electronics will be handled by our Arduino and LED Shield: Youtube.com
- Create a new folder in your Arduino folder named LightSculpture.
- Create a new sketch and save it in the LightSculpture folder as YourInitials_PulseWidthModulation.ino
- Copy and complete the following sketch template:
- Move setup and loop into the Main Functions section.
- Copy the "Light Sculpture Helpers" function definitions from the previous exercise into the Helper Functions section.
- Open, read, and refer to the dpeaArduinoStyleGuide.
/* Light Sculpture Pulse Width Modulation - Written by - Updated */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Function Declarations (verbs) //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void pwmUsingKnob();
void updateKnobValue();
void turnOnArray( const byte arrayName[], const byte arrayLength);
void turnOffArray(const byte arrayName[], const byte arrayLength);
void turnOnAll();
void turnOffAll();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Global Variable Declarations (nouns) //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Main Functions //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Knob Functions //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Helper Functions //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Current Objective (Global Variable Declaration)
- Modulate the duty cycle (onTime) of the LEDs using the knob voltage.
- Declare the global variables controlling the knob and pulse width modulation (PWM).
Requirements
- Cleanly format your code to maximize organization and readability like the dpeaArduinoStyleGuide.
- Clarify the purpose of each function and variable through smart naming.
- Use headers and comments as needed to enhance organization.