#include<avr/io.h>
#include<util/delay.h>
#include "uart.h"
void ADC_Init();
float read_adc();
unsigned char ADC_calculating();
unsigned char a;
unsigned char b;
void main()
{
char temp;
_delay_ms(50);
UART_Init(25);
UART_TransmitString("To Display the Temperature in Centigrade \r\n");
ADC_Init();
while(1)
{
//convert calue to tempature
temp = ADC_calculating();
a = temp % 10;
b = temp / 10;
_delay_ms(100);
UART_TransmitByte(a+48);
UART_TransmitByte(b+48);
UART_TransmitString("\r\n");
_delay_ms(100);
}
}
void ADC_Init()
{
ADMUX = (1<<REFS0);
ADCSRA = 0x85;
}
float read_adc()
{
//select the ADC channel
ADMUX |= _BV(0);
//START THE ADC CONVERATION
ADCSRA |= (1<<ADSC);
//WAIT FOR CONVERATION TO COMPLETE
while(!(ADCSRA) & (1<< ADIF));
//CLEAR ADIF BY WRITING ONE TO IT
ADCSRA |= (1<< ADIF);
return(ADC);
}
unsigned char ADC_calculating()
{
float ADC_VALUE = 0;
float value=0;
ADC_VALUE = read_adc();
value = ((ADC_VALUE)* 0.48876);
return(value);
}
To Display the Temperature in Centigrade
00
8:
0<
4<
+$
0$
'%
*%
/%
'&
'&
(&
+&
,&
/&
)'
+'
*'
-'
0'
0'
0'
)(
*(
)(
+(
-(
-(
,(
.(
/(
.(
/(
()
')
0(
()
))
()
()
+)
+)
))
+)
,)
+)
+)
.)
.)
,)
-)
/)
.)
-)
/)
0)
.)
.)
0)
.)
-)
/)
/)
.)
.)
/)
/)
.)
/)
0)
/)
/)
0)
/)
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?