Created
September 27, 2016 14:01
-
-
Save anonymous/07e1178f2ef63ad9facb8abe1d03eb29 to your computer and use it in GitHub Desktop.
EA641 - Lab de Eletrônica 2 - Código 2 - Exp 3
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> | |
#include <math.h> | |
#define PORT 0 | |
#define PORT 1 | |
#define PORT 4 | |
#define PORT 5 | |
#define PORT 6 | |
#define PORT 7 | |
Int main (void) | |
{ | |
wiringPiSetup (); | |
pinMode (0, INPUT); | |
pinMode (1, OUTPUT); | |
pinMode (4, OUTPUT); | |
pinMode (5, OUTPUT); | |
pinMode (6, OUTPUT); | |
pinMode (7, OUTPUT); | |
int h=0,l=0,t=0,i=0; | |
float dc=0,T; | |
int r; | |
for(;;) | |
{ | |
digitalWrite(6,HIGH); | |
digitalWrite(4,HIGH); | |
digitalWrite(6,LOW); | |
delay(1000); | |
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) // 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. | |
digitalWrite(6,HIGH); | |
digitalWrite(4,LOW); | |
digitalWrite(6,LOW); | |
delay(1000); | |
else | |
digitalWrite(6,HIGH); | |
digitalWrite(4,HIGH); | |
digitalWrite(6,LOW); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment