Skip to content

Instantly share code, notes, and snippets.

@johnaboxall
Created August 1, 2019 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnaboxall/f5a053523d59cf216aaf5f9c05bf3f2d to your computer and use it in GitHub Desktop.
Save johnaboxall/f5a053523d59cf216aaf5f9c05bf3f2d to your computer and use it in GitHub Desktop.
Example 1-2 - PWM
int i = 1000;
void setup()
{
pinMode(3, OUTPUT); // sets digital pin 3 to an output
pinMode(6, OUTPUT); // sets digital pin 6 to an output
}
void loop()
{
analogWrite(3, 255); // 100% duty cycle
analogWrite(6, 255); // 100% duty cycle
delay(i);
analogWrite(3, 191); // 75% duty cycle
analogWrite(6, 191); // 75% duty cycle
delay(i);
analogWrite(3, 127); // 50% duty cycle
analogWrite(6, 127); // 50% duty cycle
delay(i);
analogWrite(3, 63); // 25% duty cycle
analogWrite(6, 63); // 25% duty cycle
delay(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment