Skip to content

Commit

Permalink
Added an example
Browse files Browse the repository at this point in the history
  • Loading branch information
ocrdu committed Dec 16, 2019
1 parent a8a7b9b commit d7bce9f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions examples/flame/flame.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Uses two orange LEDS plus resistors on pins 4 and 7 (on the Nano 33 IoT; change for other boards).
// Don't pull more than 7mA from any pin.

#include <SAMD21turboPWM.h>

TurboPWM pwm;

void setup() {
pwm.setClockDivider(1, false);
pwm.timer(1, 1, 1000, true);
}

void loop() {
pwm.analogWrite(4, random(500, 1000));
delay(25);
pwm.analogWrite(7, random(300, 1000));
delay(25);
}
2 changes: 1 addition & 1 deletion src/SAMD21turboPWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int TurboPWM::timer(int timerNumber, unsigned int TCCDiv, unsigned long int sts,
return 0;
}

// Derive TCC prescaler from parameter TCCDiv; default to 4
// Derive TCC prescaler from parameter TCCDiv; default to last known setting
unsigned int my_TCC_CTRLA_PRESCALER_DIV;
if (TCCDiv == 1) {
my_TCC_CTRLA_PRESCALER_DIV = TCC_CTRLA_PRESCALER_DIV1_Val << TCC_CTRLA_PRESCALER_Pos;
Expand Down

0 comments on commit d7bce9f

Please sign in to comment.