Created
August 30, 2016 14:32
-
-
Save anonymous/e38a68396687b69aba3f3fb7da193bcb to your computer and use it in GitHub Desktop.
Exp 1 - Laboratório de Eletrônica 2 - Porcentagem de Duty Cycle de um sinal - Conversor Analógico Digital
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
#include <stdio.h> | |
#include <wiringPi.h> | |
//LED Pin - wiringPi pin 0 is BCM_GPIO 17 | |
#define PORT 0 | |
int main(void) | |
{ | |
wiringPiSetup(); | |
pinMode(0,INPUT); | |
int h=0,l=0,i=0,r; | |
float dc=0; | |
for (i;i<100;i++) | |
{r=digitalRead(0); | |
if(r==1) | |
{ | |
h=h+1 | |
} | |
delay(1); | |
} | |
dc=(float)h/i; | |
printf("%f \n ", dc); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment