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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
| // initialisation afficheur LCD
// Lcd pinout settings
sbit LCD_RS at RC4_bit;
sbit LCD_EN at RC5_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D4 at RC0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISC4_bit;
sbit LCD_EN_Direction at TRISC5_bit;
sbit LCD_D7_Direction at TRISC3_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISC0_bit;
unsigned char acqui ;
// variables enables to store temperature and humidity digital values
unsigned temp;
float long temp_o; // originals values of temperature and humidity
unsigned char i,j, valueT[7],testT[14];
char *hu;
void Move_Delay() { // Function used for text moving
Delay_ms(200); // You can change the moving speed here
}
void main() {
TRISA=0xFF;
Lcd_Init();
// displaying information of LCD screen
Lcd_Cmd(_LCD_CLEAR); LCD_cmd(_LCD_CURSOR_OFF);
Lcd_Out(0, 6, "TEMP:");
//######-- started sensor temperature
temp = ADC_Read(0); // digital value ie InputValue/q where q=5/1023
temp_o = temp*(5.0/1023.0); //conversion for obtain the original input in volatge
temp_o = temp_o * 100; // three ruler enable to obtain the corresponding degree
temp = (int)temp_o ;
temp = (temp> 5) ? (temp):(temp+1); // exact value of sensor
LongToStr(temp,testT);
j = 0;
for(i = 0;i<=11;i++)
{
if(testT[i]!=' ')
{
valueT[j] = testT[i];
j++;
}
}
Lcd_Out(2,1," ");
Lcd_Out(1,12,valueT);Lcd_Out(1,15,"C");
/* the protocole that enable to send information between pic and Pc as follows:
- when we send the temperature, we send firstly letter "T" like temperature
- if a percent humidity, we send firstly letter "H" */
UART1_Write_Text("T");
UART1_Write_Text(valueT);
// UART1_Write_Text("°C");
/*##########Interval testing started###########*/
if( (temp >=0) && (temp < 36) ) {
//enclosure is cool
Lcd_Out(2,6, " ") ;
Lcd_Out(2,6, "Cool") ;
}
else if((temp >=36) && (temp < 38)){
// temperature is normal
Lcd_Out(2,6, " ") ;
Lcd_Out(2,3, "Normal Temp") ;
}
else {
// temperature is too hot
Lcd_Out(2,6, " ") ;
Lcd_Out(2,6, "Too Hot") ;
// Moving text
while(1) { // Endless loop
for(i=0; i<5; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
for(i=0; i<5; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}
}
//###########---end sensor temperature----###########
}
while(1);
} |