Skip to content

Commit

Permalink
Added example
Browse files Browse the repository at this point in the history
  • Loading branch information
soylentOrange committed May 8, 2023
1 parent 1ce9f67 commit d99023c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/DigiSpark_PWM_example/DigiSpark_PWM_example.ino
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
}

0 comments on commit d99023c

Please sign in to comment.