-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ce9f67
commit d99023c
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* DigiSpark_PWM Library | ||
soylentOrange - https://github.com/soylentOrange/DigiSpark_PWM | ||
*/ | ||
|
||
#include "DigiSpark_PWM.h" // https://github.com/soylentOrange/DigiSpark_PWM | ||
|
||
uint8_t g_dutyCycle; // DC in % | ||
uint32_t g_frequency; // frequency in Hz | ||
|
||
// Cretae instance of DigiSpark_PWM-class, connected to Pin-PB1 | ||
// (This Pin is connected to the onboard LED) | ||
DigiSpark_PWM pwm = DigiSpark_PWM(PIN_PB1); | ||
|
||
// For connecting to Pin PB4 simply use: | ||
// DigiSpark_PWM pwm = DigiSpark_PWM(); | ||
|
||
// begin PWM-output | ||
void setup() { | ||
// initialize and start PWM-output @1Hz with 50% duty-cycle | ||
g_frequency = 1; // 1Hz | ||
g_dutyCycle = 50; // 50% | ||
pwm.begin(g_frequency, g_dutyCycle); | ||
} | ||
|
||
void loop() { | ||
// nothing to do here, the LED will blink driven by the hardware PWM | ||
} |