Hallo everyone, i have this code as to read the temprature with pt100 in arduino.
But i want to connect an LED and a botton as to turn on LED blink unti 250' Celsius and when reached on 250' the LED start blinking for 3 times . each time half second, and after 5 second LED trun completely off.
i request you please help me complete this code.
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // i2c library for lcd
LiquidCrystal_I2C lcd(0x27,16,2); //i2c address 0x27
unsigned long time1 = 0;
const int analogInPin = A0; // signal pin of pt100 connected to pin A0
const int SensorValueLow = 463;
const int SensorValueDiff = 36;
const int TempValueDiff = 42;
const int TempValueLow = 9;
int sensorValue = 0;
double Temp = 0;
#define minTempC 0 // about 109F
#define maxTempC 150 // about 183F
#define startTempC 29 // initial set temperature value
float setTempC;
#define buttonDN 5 // push button pin 1 connect digital pin 4
#define buttonUP 4 // push button pin 2 connect digital pin 5
#define role 8 // relay pin connect digital pin 8
#define coi 3
byte degree[8] = { // this line to display degrees C
0B01110,
0B01010,
0B01110,
0B00000,
0B00000,
0B00000,
0B00000,
0B00000
};
void setup()
{
Serial.begin(9600);
pinMode(buttonDN, INPUT_PULLUP);
pinMode(buttonUP, INPUT_PULLUP);
pinMode(role, OUTPUT);//SIZE ROLAY CHAN
pinMode(coi, OUTPUT);//how much
digitalWrite(coi,HIGH);
setTempC = startTempC;
}
void loop()
{
sensorValue = analogRead(analogInPin);
Temp = sensorValue-SensorValueLow;
Temp = Temp/SensorValueDiff;
Temp = Temp*TempValueDiff;
Temp = Temp+TempValueLow;
Temp = Temp - 32;
setTemperature();
setHeater();
displayLCD();
}
void displayLCD(){
lcd.init();
lcd.backlight();// tarpaulin turns off the LCD screen
lcd.clear();
lcd.home ();
Serial.print("C = ");
Serial.println(Temp);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.setCursor(10,0);
lcd.print(Temp);
lcd.print("");
lcd.write(1);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("bis : ");
lcd.setCursor(5,1);
lcd.print(round(setTempC));
lcd.print("");
lcd.write(1);
lcd.print("C");
lcd.createChar(1, degree);
}
void setTemperature()
{
if (digitalRead(buttonDN)==HIGH){ // Where the push button is pressed
setTempC++; // increase the setting value by 1 unit
if(setTempC < minTempC) setTempC = minTempC;
}
if (digitalRead(buttonUP)==HIGH){
setTempC--;// decrease the setting value by 1 unit
if(setTempC > maxTempC) setTempC = maxTempC;
}
}
void setHeater()
{
if ((setTempC) > (Temp + 0.5 ) ) {
digitalWrite(role, LOW);
lcd.setCursor(11,1);
lcd.print("up");
//delay(10000);
}
else if ((setTempC) <= (Temp - 0.5)){
digitalWrite(role, HIGH);
//digitalWrite(coi, LOW);
beep();
lcd.setCursor(11,1);
lcd.print("Done");
// delay(10000);
}
}
void beep() { // The buzzer sounds when the set temperature is less than the current temperature
digitalWrite(coi, LOW);
delay(800);
digitalWrite(coi, HIGH);
delay(800);
}