Skip to content

Instantly share code, notes, and snippets.

@giacobo1
Created December 14, 2015 05:01
Show Gist options
  • Save giacobo1/7d4bbb5fb65b873d55a6 to your computer and use it in GitHub Desktop.
Save giacobo1/7d4bbb5fb65b873d55a6 to your computer and use it in GitHub Desktop.
PWM FUNCTION
#include <stdlib.h>
#include <stdio.h>
short PWM1_SET_DUTY( short cont, short q, short MAX ) {
if (cont >=0 && cont < MAX) {
cont += q;
}
return cont;
}
int main(int argc, char * argv[]) {
short cont = 0;
int i = 0;
for (i; i < atoi(argv[1]); i++) {
cont = PWM1_SET_DUTY(cont, 25, 255);
}
printf("%d\n", cont);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment