Skip to content

Commit d7bce9f

Browse files
committed
Added an example
1 parent a8a7b9b commit d7bce9f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

examples/flame/flame.ino

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Uses two orange LEDS plus resistors on pins 4 and 7 (on the Nano 33 IoT; change for other boards).
2+
// Don't pull more than 7mA from any pin.
3+
4+
#include <SAMD21turboPWM.h>
5+
6+
TurboPWM pwm;
7+
8+
void setup() {
9+
pwm.setClockDivider(1, false);
10+
pwm.timer(1, 1, 1000, true);
11+
}
12+
13+
void loop() {
14+
pwm.analogWrite(4, random(500, 1000));
15+
delay(25);
16+
pwm.analogWrite(7, random(300, 1000));
17+
delay(25);
18+
}

src/SAMD21turboPWM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int TurboPWM::timer(int timerNumber, unsigned int TCCDiv, unsigned long int sts,
6161
return 0;
6262
}
6363

64-
// Derive TCC prescaler from parameter TCCDiv; default to 4
64+
// Derive TCC prescaler from parameter TCCDiv; default to last known setting
6565
unsigned int my_TCC_CTRLA_PRESCALER_DIV;
6666
if (TCCDiv == 1) {
6767
my_TCC_CTRLA_PRESCALER_DIV = TCC_CTRLA_PRESCALER_DIV1_Val << TCC_CTRLA_PRESCALER_Pos;

0 commit comments

Comments
 (0)