hai,
i'm creating a temperature controller using peltier tec12706 and LM35...my programming should be very simple the peltier will be activated whenever the temperature is below 33c. my circuit consist of relay connected to the peltier. firstly i'm using the relay module but whenever the temperature is below 33celcius and relay is actived the LM35 reading become unstable then i change my circuit without using a relay module. circuit that consist of transistor,diode,10k resistor and 5v relay. the problem still not fixed. but when i'm try stimulated it using the same circuit and coding using proteus the system work just fine.is there something wrong with my coding? i'm using arduino uno. below is my coding. thanks in advance.
// include the library code:
#include <LiquidCrystal.h>
#define sensor 0 // Define the A0 pin as “sensor”la
#define relay 8
int Vin; // Variable to read the value from the Arduino’s pin
float Temperature; // Variable that receives the converted voltage value to temperature
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
pinMode(relay,OUTPUT);
}
void loop() {
Vin = analogRead (sensor); /* Tells the Arduino to read the pin and stores the value in “Vin” */
Temperature=(5.0Vin100.0)/1024; /* Converts the voltage value into temperature and stores it into the “Temperature” variable (in ºC)*/
lcd.setCursor(0, 0);
lcd.print("Temp:");
lcd.print(Temperature);
lcd.print(" C");
delay(1000);
if(Temperature<33)
{
digitalWrite(relay, HIGH);
lcd.print("on");
}
else{
digitalWrite(relay, LOW);
lcd.print("off");
}
}