Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2016 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e38a68396687b69aba3f3fb7da193bcb to your computer and use it in GitHub Desktop.
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
#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