-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharduinocode
68 lines (65 loc) · 1.78 KB
/
arduinocode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//to input the test temperature, display it and as well as display the increasing temperatures.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
int relay=9;
int pump=10;
char Tempc;
int temp=1;
String temp_S="";
float sensor_temp;
char octaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {1,2,3,4};
byte colPins[COLS] = {5,6,7,8};
Keypad customKeypad = Keypad(makeKeymap(octaKeys), rowPins, colPins, ROWS, COLS); //mapping my whole keypad
LiquidCrystal_I2C lcd(0x21, 16, 2);
void setup(){
lcd.backlight();
lcd.init();
digitalWrite(relay,LOW);
Serial.begin(9600);
}
void loop()
{
while(Tempc!='C') //only made in centigradfe. can give them farenheit facility too. discuss.
{
Tempc = customKeypad.getKey();
temp=(temp*10)+atoi(Tempc);
temp_S+=Tempc;
if (Tempc){
lcd.clear(); //clear screening
lcd.setCursor(0, 0);
lcd.print(Tempc); //displaying inputted temperature
}
}
//temp=temp_S.toFloat();
digitalWrite(relay,HIGH);
Serial.println(" Stopping temperature is: "+temp);//integer stopping temperature
//after this lcd will display the sensor read temperatures
int value=analogRead(A0); //read from A0
int volts=(value/1024)*5; //conversion to volts
sensor_temp= volts*100; //conversion to temp Celsius
if(sensor_temp==(temp+5)) //assuming temperature loss is 5
{
digitalWrite(relay,LOW);
digitalWrite(pump, HIGH);
Serial.println("PUMP IS STARTING TO WORK ARDUINO DID IT'S WORK");
delay(10000);
}
else
{
Serial.print("Temperature= ");
Serial.println(temp);
lcd.setCursor(0,0);
lcd.print("TEMP= ");
lcd.print(sensor_temp);
lcd.print(" C");
}
}