Mithun_K_Das
Advanced Member level 3

- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 27
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
unsigned int adc_rd2;
unsigned char ch;
float temp;
int sample[20];
float average = 0;
// LCD module connections
sbit LCD_RS at PORTD7_bit;
sbit LCD_EN at PORTB0_bit;
sbit LCD_D4 at PORTB4_bit;
sbit LCD_D5 at PORTB3_bit;
sbit LCD_D6 at PORTB2_bit;
sbit LCD_D7 at PORTB1_bit;
sbit LCD_RS_Direction at DDD7_bit;
sbit LCD_EN_Direction at DDB0_bit;
sbit LCD_D4_Direction at DDB4_bit;
sbit LCD_D5_Direction at DDB3_bit;
sbit LCD_D6_Direction at DDB2_bit;
sbit LCD_D7_Direction at DDB1_bit;
// End LCD module connections
//
int i;
char txt[10];
char *text;
long tlong;
void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
DDRC = 0b11111110;
while(1)
{
for(i=0; i< 5; i++)
{
adc_rd2 = ADC_Read(0);
sample[i] = adc_rd2;
Delay_ms(20);
}
average = 0;
for(i=0;i<5;i++)
{
average += sample[i];
}
average /= 5;
average = ((1023 /(float)adc_rd2 )-1);;
average = 10000/average; // get the resitror value
temp = average/10000; // R/Ro
temp = log(temp); // temp = log(R/Ro)
temp /= 3950; // 1/B
temp += 1.0/(25.00 + 273.15);
temp = 1.00/temp;
temp -= 273.15; // convert to C.
tlong = temp*1000;
ch = tlong/1000; // Extract volts (thousands of millivolts)
ch = (tlong / 100000) % 10;
Lcd_Chr(2,9,48+ch); // Write result in ASCII format
ch = (tlong / 10000) % 10;
Lcd_Chr_Cp(48+ch); // Write result in ASCII format
ch = (tlong / 1000) % 10;
Lcd_Chr_Cp(48+ch); // Write result in ASCII format
Lcd_Chr_CP('.');
ch = (tlong / 100) % 10; // Extract hundreds of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
ch = (tlong / 10) % 10; // Extract tens of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
Lcd_Chr_CP('C');
Lcd_Out(1,2,"Recent Temp:");
PORTC4_bit = ~PORTC4_bit;
}// while
} // void
need to know , which crystal you using and the type of micro controller. btw now the commonly available UCs are atmega 8L s which have max crystal frequency of 8 Mhz. So if its above 8Mhz, chances of it working are dim.