Diferencia entre revisiones de «Mini horno»

De fabwiki
Ir a la navegación Ir a la búsqueda
Sin resumen de edición
Sin resumen de edición
 
Línea 1: Línea 1:
<pre>
<pre>
/*
/*
  *
  *
Línea 9: Línea 10:
  *          10K thermistor    10K resistor
  *          10K thermistor    10K resistor
  */
  */
#include <SmoothThermistor.h>
#include <SmoothThermistor.h>


float t_objectivo = 15;
float t_objectivo = 15;
const int CALENTADOR = 12;


SmoothThermistor smoothThermistor(A0,              // the analog pin to read from
SmoothThermistor smoothThermistor(A0,              // the analog pin to read from
Línea 24: Línea 28:
   Serial.begin(9600);
   Serial.begin(9600);
   smoothThermistor.useAREF(true);
   smoothThermistor.useAREF(true);
   pinMode(12, OUTPUT);
   pinMode(CALENTADOR, OUTPUT);
   pinMode(13, OUTPUT);
   pinMode(13, OUTPUT);
}
}
Línea 30: Línea 34:
void loop() {
void loop() {
   float t_actual = smoothThermistor.temperature();
   float t_actual = smoothThermistor.temperature();
 
  Serial.print("min:");
   Serial.print("t_objectivo:");
  Serial.print(13);
  Serial.print(" max:");
  Serial.print(23);
   Serial.print(" t_objectivo:");
   Serial.print(t_objectivo);
   Serial.print(t_objectivo);
   Serial.print(" ");
   //Serial.print(" ");
   Serial.print("t_actual:");
   Serial.print(" t_actual:");
   Serial.println(t_actual);
   Serial.println(t_actual);


Línea 49: Línea 56:
   }
   }
   
   
   digitalWrite(12, calentar);
   digitalWrite(CALENTADOR, calentar);
   digitalWrite(13, calentar);
   digitalWrite(13, calentar);
   delay(1000);
   delay(1000);
}
}
</pre>
</pre>

Revisión actual - 16:00 4 jul 2026


/*
 *
 *          AREF      Analog pin 0
 *           |              |
 *    3.3V |-+---/\/\/\-----+-----/\/\/\-----| GND
 *
 *                 ^                ^ 
 *          10K thermistor     10K resistor
 */
 
#include <SmoothThermistor.h>

float t_objectivo = 15;

const int CALENTADOR = 12;

SmoothThermistor smoothThermistor(A0,              // the analog pin to read from
                                   ADC_SIZE_10_BIT, // the ADC size
                                   10000,           // the nominal resistance
                                   10000,           // the series resistance
                                   3950,            // the beta coefficient of the thermistor
                                   25,              // the temperature for nominal resistance
                                   10);             // the number of samples to take for each measurement

void setup() {
  Serial.begin(9600);
  smoothThermistor.useAREF(true);
  pinMode(CALENTADOR, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop() {
  float t_actual = smoothThermistor.temperature();
  Serial.print("min:");
  Serial.print(13);
  Serial.print(" max:");
  Serial.print(23); 
  Serial.print(" t_objectivo:");
  Serial.print(t_objectivo);
  //Serial.print(" ");
  Serial.print(" t_actual:");
  Serial.println(t_actual);

  if (Serial.available() != 0) {
    float temp = Serial.parseFloat();
    if (temp > 0.0) t_objectivo = temp;
  }

  bool calentar = false;
  if (t_actual < t_objectivo) {
    calentar = true;
  } else {
    calentar = false;
  }
 
  digitalWrite(CALENTADOR, calentar);
  digitalWrite(13, calentar);
  delay(1000);
}