Created
September 15, 2016 03:56
-
-
Save anonymous/70caefd8ea3fb216eeb75321d6ab95fe to your computer and use it in GitHub Desktop.
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.n> | |
#include <math.h> | |
//LED Pin - wiringPi pin 8 is BCM_GPIO 17. | |
#define PORT 0 | |
int main (void) | |
{ | |
wiringPiSetup (); | |
pinMode (0, INPUT); | |
int h,l,i,r; | |
float dc,T; | |
for(;;) | |
{ | |
delay (50); | |
h = 0; | |
for (i=0; i<1000000; i++) | |
{ | |
r = digitalRead (0); | |
if (r==1) | |
{ | |
h = h + 1; | |
} | |
} | |
dc = (float) h/i; | |
T = -(1/0.034)+log((6.09*(1-dc))/2*dc)); | |
printf ("%f \n", T); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment