Paso 3: el código
/***********************************************************************************/
Declarar la potencimeter y la temperatura de pines del sensor
const int potenciometro = A1;
const int Temperatura = 0;
declarar cada pin del led
const int led1 = 9;
const int led2 = 8;
const int led3 = 7;
const int led4 = 6;
const int led5 = 5;
const int led6 = 4;
const int led7 = 3;
const int led8 = 2;
const int led9 = 1;
const int led10 = 0;
Declarar las variables para la regulación de temperatura
int pot_regulador = 0;
int ajuste_de_temp = 0;
declarar los leds como salidas
void setup() {}
pinMode (led1, salida);
pinMode (led2, salida);
pinMode (led3, salida);
pinMode (led4, salida);
pinMode (led5, salida);
pinMode (led6, salida);
pinMode (led7, salida);
pinMode (led8, salida);
pinMode (led9, salida);
pinMode (led10, salida);
}
principal del programa
void loop() {}
leer voltaje del sensor de temperatura y transformar a grados celsius
lectura de int = analogRead(Temperatura);
voltaje del flotador = lectura * 5.0;
voltaje = 1024.0;
Float TemperaturaC = (voltaje - 0.5) * 100;
Esta parte si para regular la temperatura
en este programa nos divida el valor del potenciómetro por 30 a 30 grados de la regulación
Si se divide por 100 tiene 10 grados de regulación
y dividido por 50 consigues 20 grados de regulación
los valores son solo aproximados no son exactos
pot_regulador=analogRead(Potenciometro);
ajuste_de_temp = pot_regulador/30;
Delay(50);
la temperatura es leer y los iluminan por la temperatura que mide
Si (TemperaturaC <(10-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, LOW);
digitalWrite (LED 3, bajo);
digitalWrite (led4, LOW);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(20-ajuste_de_temp) & & TemperaturaC >(10-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, bajo);
digitalWrite (led4, LOW);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(30-ajuste_de_temp) & & TemperaturaC >(20-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, LOW);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(40-ajuste_de_temp) & & TemperaturaC >(30-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(50-ajuste_de_temp) & & TemperaturaC >(40-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(60-ajuste_de_temp) & & TemperaturaC >(50-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(70-ajuste_de_temp) & & TemperaturaC >(60-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(80-ajuste_de_temp) & & TemperaturaC >(70-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, HIGH);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(90-ajuste_de_temp) & & TemperaturaC >(80-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, HIGH);
digitalWrite (led9, HIGH);
digitalWrite (led10, LOW);
}
else if (TemperaturaC <(100-ajuste_de_temp) & & TemperaturaC >(90-ajuste_de_temp)) {}
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, HIGH);
digitalWrite (led9, HIGH);
digitalWrite (led10, HIGH);
}
}
/****************************************************************************************/