Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int input = 7;
- unsigned long duracion,actual;
- float temp;
- void setup() {
- Serial.begin(9600);
- }
- void loop() {
- duracion = 0; //Reseteamos los valores
- for (int x=0; x<30; x++){
- actual = pulseIn(input, HIGH); //Medimos el tiempo en ON de la señal
- if (actual > duracion){
- duracion = actual; //Tomamos el mayor valor de 30 muestras
- }
- delay(30); //Hacemos una pausa
- }
- temp = 2 * duracion; //Calculamos la temperatura con el periodo de la señal
- temp = 225 - temp/5;
- Serial.println(temp);
- delay(300);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement