[syntax = mikroC]
#define high 1;
#define low 0;
// LCD module connections
sbit LCD_RS at P3_4_bit;
sbit LCD_EN at P3_5_bit;
sbit LCD_D4 at P2_4_bit;
sbit LCD_D5 at P2_5_bit;
sbit LCD_D6 at P2_6_bit;
sbit LCD_D7 at P2_7_bit;
// End LCD module connections
int temp_limit;
float adc_val;
char myStr[23];
void main() {
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"89S52 and LM35 Based");
Lcd_Out(2,1,"Temperature Monitor");
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
temp_limit = 27;
do {// Function for A-D conversion
P3_6_bit = low; //WR = 0
P3_6_bit = high; //WR = 1
if (P3_2_bit == 0) { //INTR of 0804 = 0?
P3_7_bit = low; //RD = 0
adc_val = P0; //0804 [D0-D7] = P0 [89S52]
}
FloatToStr(adc_val, myStr);
Lcd_Out(2,1,myStr);
if (adc_val > temp_limit) {
P1_1_bit = 1;
}
else {
P1_1_bit = 0;
}
} while(1);
}
[/SYNTAX]