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.

Revisions

  1. giacobo1 renamed this gist Dec 14, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. giacobo1 created this gist Dec 14, 2015.
    28 changes: 28 additions & 0 deletions .c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #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;
    }