Created
September 15, 2016 04:07
-
-
Save anonymous/27a2552b29599a4774375d231575434a 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); | |
if(T>25) digitalWrite(1,HIGH); // 25 é nossa temperatura máxima, que caso ultrapassada aciona a lâmpada. Caso o projeto for comercializado, é recomendável trocar o número 25, por uma variável, realizar um scanf dessa varíavel e então o próprio cliente pode determinar o Tmax, desde que esteja entre 20-50 graus determinado na hora de projetar o circuito. | |
esle digitalWirte(1,LOW); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment